Skip to content

Commit fd7416e

Browse files
committed
Tweak library
1 parent afc5afb commit fd7416e

File tree

3 files changed

+10
-21
lines changed

3 files changed

+10
-21
lines changed

library/src/scala/collection/concurrent/TrieMap.scala

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -314,9 +314,7 @@ private[collection] final class INode[K, V](bn: MainNode[K, V], g: Gen, equiv: E
314314
startgen: Gen,
315315
ct: TrieMap[K, V]): Option[V] = {
316316

317-
val m = GCAS_READ(ct) // use -Yinline!
318-
319-
m match {
317+
GCAS_READ(ct) match {
320318
case cn: CNode[K, V] =>
321319
val idx = (hc >>> lev) & 0x1f
322320
val bmp = cn.bitmap
@@ -343,8 +341,8 @@ private[collection] final class INode[K, V](bn: MainNode[K, V], g: Gen, equiv: E
343341
if (res == None || (res eq null)) res
344342
else {
345343
@tailrec def cleanParent(nonlive: AnyRef): Unit = {
346-
val pm = parent.GCAS_READ(ct)
347-
pm match {
344+
val cn = parent.GCAS_READ(ct)
345+
cn match {
348346
case cn: CNode[K, V] =>
349347
val idx = (hc >>> (lev - 5)) & 0x1f
350348
val bmp = cn.bitmap

library/src/scala/collection/convert/JavaCollectionWrappers.scala

Lines changed: 5 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -456,22 +456,13 @@ private[collection] object JavaCollectionWrappers extends Serializable {
456456

457457
def underlyingConcurrentMap: concurrent.Map[K, V] = underlying
458458

459-
override def putIfAbsent(k: K, v: V) = underlying.putIfAbsent(k, v) match {
460-
case Some(v) => v
461-
case None => null.asInstanceOf[V]
462-
}
459+
override def putIfAbsent(k: K, v: V) = underlying.putIfAbsent(k, v).getOrElse(null.asInstanceOf[V])
463460

464-
override def remove(k: AnyRef, v: AnyRef) = try {
465-
underlying.remove(k.asInstanceOf[K], v.asInstanceOf[V])
466-
} catch {
467-
case ex: ClassCastException =>
468-
false
469-
}
461+
override def remove(k: AnyRef, v: AnyRef) =
462+
try underlying.remove(k.asInstanceOf[K], v.asInstanceOf[V])
463+
catch { case ex: ClassCastException => false }
470464

471-
override def replace(k: K, v: V): V = underlying.replace(k, v) match {
472-
case Some(v) => v
473-
case None => null.asInstanceOf[V]
474-
}
465+
override def replace(k: K, v: V): V = underlying.replace(k, v).getOrElse(null.asInstanceOf[V])
475466

476467
override def replace(k: K, oldval: V, newval: V) = underlying.replace(k, oldval, newval)
477468
}

library/src/scala/collection/immutable/RedBlackTree.scala

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -31,8 +31,8 @@ private[collection] object RedBlackTree {
3131

3232
def contains[A: Ordering](tree: Tree[A, _], x: A): Boolean = lookup(tree, x) ne null
3333
def get[A: Ordering, B](tree: Tree[A, B], x: A): Option[B] = lookup(tree, x) match {
34-
case null => None
35-
case tree => Some(tree.value)
34+
case null => None
35+
case found => Some(found.value)
3636
}
3737

3838
@tailrec

0 commit comments

Comments
 (0)