Skip to content

Commit 48e4697

Browse files
committed
Rewrite linkedListLoop in removeStaleEntries
1 parent 41bf2eb commit 48e4697

File tree

1 file changed

+4
-5
lines changed

1 file changed

+4
-5
lines changed

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

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ import java.lang.ref.{ReferenceQueue, WeakReference}
66

77
import scala.annotation.{ constructorOnly, tailrec }
88

9-
import dotty.tools.uncheckedNN
9+
import dotty.tools._
1010

1111
/**
1212
* A HashSet where the elements are stored weakly. Elements in this set are eligible for GC if no other
@@ -92,10 +92,9 @@ abstract class WeakHashSet[A <: AnyRef](initialCapacity: Int = 8, loadFactor: Do
9292

9393
@tailrec
9494
def linkedListLoop(prevEntry: Entry[A] | Null, entry: Entry[A] | Null): Unit =
95-
if (stale == entry)
96-
assert(entry != null)
97-
remove(bucket, prevEntry, entry)
98-
else if (entry != null) linkedListLoop(entry, entry.tail)
95+
if entry != null then
96+
if stale eq entry then remove(bucket, prevEntry, entry)
97+
else linkedListLoop(entry, entry.tail)
9998

10099
linkedListLoop(null, table(bucket))
101100

0 commit comments

Comments
 (0)