summaryrefslogtreecommitdiff
path: root/src/library/scala/collection/MapLike.scala
diff options
context:
space:
mode:
authorPaul Phillips <paulp@improving.org>2011-06-23 06:13:55 +0000
committerPaul Phillips <paulp@improving.org>2011-06-23 06:13:55 +0000
commitb924c4142de1ca6525a3d5e57ecfb7a345dd9f89 (patch)
tree6d098958841f8c842b1cfda00e032bf1f96e2f2e /src/library/scala/collection/MapLike.scala
parent8ba9b511c2b11d0514013bb1e18cbc8a7b9e5f5c (diff)
downloadscala-b924c4142de1ca6525a3d5e57ecfb7a345dd9f89.tar.gz
scala-b924c4142de1ca6525a3d5e57ecfb7a345dd9f89.tar.bz2
scala-b924c4142de1ca6525a3d5e57ecfb7a345dd9f89.zip
Overrode contains and apply in mutable.HashMap ...
Overrode contains and apply in mutable.HashMap to avoid allocating an unnecessary Some on every call to either of them. Fruit looks a little better defended in immutable.HashMap, so I deleted a bunch of old debugging code instead. Closes #4469, no review.
Diffstat (limited to 'src/library/scala/collection/MapLike.scala')
-rw-r--r--src/library/scala/collection/MapLike.scala5
1 files changed, 1 insertions, 4 deletions
diff --git a/src/library/scala/collection/MapLike.scala b/src/library/scala/collection/MapLike.scala
index f6a5c57ddf..4850898ce8 100644
--- a/src/library/scala/collection/MapLike.scala
+++ b/src/library/scala/collection/MapLike.scala
@@ -141,10 +141,7 @@ self =>
* @param key the key
* @return `true` if there is a binding for `key` in this map, `false` otherwise.
*/
- def contains(key: A): Boolean = get(key) match {
- case None => false
- case Some(_) => true
- }
+ def contains(key: A): Boolean = get(key).isDefined
/** Tests whether this map contains a binding for a key. This method,
* which implements an abstract method of trait `PartialFunction`,