Thanks to visit codestin.com
Credit goes to github.com

Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 0 additions & 11 deletions core/js/src/main/scala/zio/internal/PlatformSpecific.scala
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,6 @@ package zio.internal

import zio.stacktracer.TracingImplicits.disableAutoTrace

import java.util.function.{Function => JFunction}
import java.util.{HashMap, HashSet, Map => JMap, Set => JSet}

private[zio] trait PlatformSpecific {
Expand Down Expand Up @@ -91,14 +90,4 @@ private[zio] trait PlatformSpecific {
final def newConcurrentMap[A, B]()(implicit unsafe: zio.Unsafe): JMap[A, B] = new HashMap[A, B]()

final def newWeakReference[A](value: A)(implicit unsafe: zio.Unsafe): () => A = { () => value }

final def computeIfAbsent[A, B](map: JMap[A, B])(key: A, mappingFunction: JFunction[A, B]): B = {
val value = map.get(key)
if (value != null) value
else {
val value = mappingFunction(key)
if (value != null) map.put(key, value)
value
}
}
}
4 changes: 0 additions & 4 deletions core/jvm/src/main/scala/zio/internal/PlatformSpecific.scala
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,6 @@ import zio.stacktracer.TracingImplicits.disableAutoTrace

import java.lang.ref.WeakReference
import java.util.concurrent.ConcurrentHashMap
import java.util.function.{Function => JFunction}
import java.util.{Collections, Map => JMap, Set => JSet, WeakHashMap}

private[zio] trait PlatformSpecific {
Expand Down Expand Up @@ -108,7 +107,4 @@ private[zio] trait PlatformSpecific {

() => ref.get()
}

final def computeIfAbsent[A, B](map: JMap[A, B])(key: A, mappingFunction: JFunction[A, B]): B =
map.computeIfAbsent(key, mappingFunction)
}
11 changes: 0 additions & 11 deletions core/native/src/main/scala/zio/internal/PlatformSpecific.scala
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,6 @@ package zio.internal

import zio.stacktracer.TracingImplicits.disableAutoTrace

import java.util.function.{Function => JFunction}
import java.util.{HashMap, HashSet, Map => JMap, Set => JSet}

private[zio] trait PlatformSpecific {
Expand Down Expand Up @@ -85,14 +84,4 @@ private[zio] trait PlatformSpecific {
val _ = a
()
}

final def computeIfAbsent[A, B](map: JMap[A, B])(key: A, mappingFunction: JFunction[A, B]): B = {
val value = map.get(key)
if (value != null) value
else {
val value = mappingFunction(key)
if (value != null) map.put(key, value)
value
}
}
}
8 changes: 7 additions & 1 deletion core/shared/src/main/scala/zio/VersionSpecific.scala
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,13 @@ private[zio] trait VersionSpecific {
type LightTypeTag = izumi.reflect.macrortti.LightTypeTag

private[zio] def taggedIsSubtype(left: LightTypeTag, right: LightTypeTag): Boolean =
Platform.computeIfAbsent(taggedSubtypes)((left, right), _ => left <:< right)
taggedSubtypes.computeIfAbsent(
(left, right),
new java.util.function.Function[(LightTypeTag, LightTypeTag), Boolean] {
override def apply(tags: (LightTypeTag, LightTypeTag)): Boolean =
tags._1 <:< tags._2
}
)

private[zio] def taggedTagType[A](tagged: EnvironmentTag[A]): LightTypeTag =
tagged.tag
Expand Down