@@ -265,17 +265,11 @@ private[collection] trait Wrappers {
265265 def += (kv : (A , B )): this .type = { underlying.put(kv._1, kv._2); this }
266266 def -= (key : A ): this .type = { underlying remove key; this }
267267
268- override def put (k : A , v : B ): Option [B ] = {
269- val r = underlying.put(k, v)
270- if (r != null ) Some (r) else None
271- }
268+ override def put (k : A , v : B ): Option [B ] = Option (underlying.put(k, v))
272269
273270 override def update (k : A , v : B ) { underlying.put(k, v) }
274271
275- override def remove (k : A ): Option [B ] = {
276- val r = underlying remove k
277- if (r != null ) Some (r) else None
278- }
272+ override def remove (k : A ): Option [B ] = Option (underlying remove k)
279273
280274 def iterator : Iterator [(A , B )] = new AbstractIterator [(A , B )] {
281275 val ui = underlying.entrySet.iterator
@@ -326,25 +320,15 @@ private[collection] trait Wrappers {
326320 * are not guaranteed to be atomic.
327321 */
328322 case class JConcurrentMapWrapper [A , B ](underlying : juc.ConcurrentMap [A , B ]) extends mutable.AbstractMap [A , B ] with JMapWrapperLike [A , B , JConcurrentMapWrapper [A , B ]] with concurrent.Map [A , B ] {
329- override def get (k : A ) = {
330- val v = underlying get k
331- if (v != null ) Some (v)
332- else None
333- }
323+ override def get (k : A ) = Option (underlying get k)
334324
335325 override def empty = new JConcurrentMapWrapper (new juc.ConcurrentHashMap [A , B ])
336326
337- def putIfAbsent (k : A , v : B ): Option [B ] = {
338- val r = underlying.putIfAbsent(k, v)
339- if (r != null ) Some (r) else None
340- }
327+ def putIfAbsent (k : A , v : B ): Option [B ] = Option (underlying.putIfAbsent(k, v))
341328
342329 def remove (k : A , v : B ): Boolean = underlying.remove(k, v)
343330
344- def replace (k : A , v : B ): Option [B ] = {
345- val prev = underlying.replace(k, v)
346- if (prev != null ) Some (prev) else None
347- }
331+ def replace (k : A , v : B ): Option [B ] = Option (underlying.replace(k, v))
348332
349333 def replace (k : A , oldvalue : B , newvalue : B ): Boolean =
350334 underlying.replace(k, oldvalue, newvalue)
@@ -380,25 +364,16 @@ private[collection] trait Wrappers {
380364 case class JDictionaryWrapper [A , B ](underlying : ju.Dictionary [A , B ]) extends mutable.AbstractMap [A , B ] with mutable.Map [A , B ] {
381365 override def size : Int = underlying.size
382366
383- def get (k : A ) = {
384- val v = underlying get k
385- if (v != null ) Some (v) else None
386- }
367+ def get (k : A ) = Option (underlying get k)
387368
388369 def += (kv : (A , B )): this .type = { underlying.put(kv._1, kv._2); this }
389370 def -= (key : A ): this .type = { underlying remove key; this }
390371
391- override def put (k : A , v : B ): Option [B ] = {
392- val r = underlying.put(k, v)
393- if (r != null ) Some (r) else None
394- }
372+ override def put (k : A , v : B ): Option [B ] = Option (underlying.put(k, v))
395373
396374 override def update (k : A , v : B ) { underlying.put(k, v) }
397375
398- override def remove (k : A ): Option [B ] = {
399- val r = underlying remove k
400- if (r != null ) Some (r) else None
401- }
376+ override def remove (k : A ): Option [B ] = Option (underlying remove k)
402377
403378 def iterator = enumerationAsScalaIterator(underlying.keys) map (k => (k, underlying get k))
404379
0 commit comments