Skip to content

Commit fc52452

Browse files
committed
Implement HashSet.-= in terms of remove, not the other way around.
1 parent 534a5b2 commit fc52452

File tree

1 file changed

+5
-8
lines changed

1 file changed

+5
-8
lines changed

compiler/src/dotty/tools/dotc/util/HashSet.scala

Lines changed: 5 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -102,7 +102,7 @@ class HashSet[T](initialCapacity: Int = 8, capacityMultiple: Int = 2) extends Mu
102102

103103
def +=(x: T): Unit = put(x)
104104

105-
def -= (x: T): Unit =
105+
def remove(x: T): Boolean =
106106
Stats.record(statsItem("remove"))
107107
var idx = firstIndex(x)
108108
var e = entryAt(idx)
@@ -124,16 +124,13 @@ class HashSet[T](initialCapacity: Int = 8, capacityMultiple: Int = 2) extends Mu
124124
hole = idx
125125
table(hole) = null
126126
used -= 1
127-
return
127+
return true
128128
idx = nextIndex(idx)
129129
e = entryAt(idx)
130+
false
130131

131-
def remove(x: T): Boolean =
132-
if contains(x) then
133-
this -= x
134-
true
135-
else
136-
false
132+
def -=(x: T): Unit =
133+
remove(x)
137134

138135
private def addOld(x: T) =
139136
Stats.record(statsItem("re-enter"))

0 commit comments

Comments
 (0)