From 889bca2de4678194ef28e24dc3513e94b5363616 Mon Sep 17 00:00:00 2001 From: Martin Odersky Date: Wed, 19 Feb 2014 11:19:41 +0100 Subject: Performance improvement: Replace == with equals in util.HashTable --- src/dotty/tools/dotc/util/HashSet.scala | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) (limited to 'src') diff --git a/src/dotty/tools/dotc/util/HashSet.scala b/src/dotty/tools/dotc/util/HashSet.scala index 32c3dbc3d..44646e2ba 100644 --- a/src/dotty/tools/dotc/util/HashSet.scala +++ b/src/dotty/tools/dotc/util/HashSet.scala @@ -30,7 +30,7 @@ class HashSet[T >: Null <: AnyRef](val label: String, initialCapacity: Int) exte var h = index(hash(x)) var entry = table(h) while (entry ne null) { - if (x == entry) + if (x equals entry) return entry.asInstanceOf[T] h = index(h + 1) @@ -49,7 +49,7 @@ class HashSet[T >: Null <: AnyRef](val label: String, initialCapacity: Int) exte def findEntry(x: T): T = { var h = index(hash(x)) var entry = table(h) - while ((entry ne null) && x != entry) { + while ((entry ne null) && !(x equals entry)) { h = index(h + 1) entry = table(h) } @@ -79,7 +79,7 @@ class HashSet[T >: Null <: AnyRef](val label: String, initialCapacity: Int) exte var h = index(hash(x)) var entry = table(h) while (entry ne null) { - if (x == entry) return + if (x equals entry) return h = index(h + 1) entry = table(h) } -- cgit v1.2.3