You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
deflinkedListLoop(entry: Entry[A]):A= entry match {
182
-
casenull=>add()
166
+
casenull=>addEntryAt(bucket, elem, h, oldHead)
183
167
case _ =>
184
168
valentryElem= entry.get
185
169
if (isEqual(elem, entryElem)) entryElem
@@ -195,7 +179,7 @@ final class WeakHashSet[A <: AnyRef](initialCapacity: Int, loadFactor: Double) e
195
179
casenull=>
196
180
case _ =>
197
181
removeStaleEntries()
198
-
valbucket=bucketFor(elem.hashCode)
182
+
valbucket=index(hash(elem))
199
183
200
184
201
185
@@ -276,6 +260,11 @@ final class WeakHashSet[A <: AnyRef](initialCapacity: Int, loadFactor: Double) e
276
260
}
277
261
}
278
262
263
+
protecteddefstatsItem(op: String) =
264
+
valprefix="WeakHashSet"
265
+
valsuffix= getClass.getSimpleName
266
+
s"$prefix$op$suffix"
267
+
279
268
/**
280
269
* Diagnostic information about the internals of this set. Not normally
281
270
* needed by ordinary code, but may be useful for diagnosing performance problems
@@ -296,9 +285,9 @@ final class WeakHashSet[A <: AnyRef](initialCapacity: Int, loadFactor: Double) e
296
285
assert(entry.get !=null, s"$entry had a null value indicated that gc activity was happening during diagnostic validation or that a null value was inserted")
297
286
computedCount +=1
298
287
valcachedHash= entry.hash
299
-
valrealHash= entry.get.hashCode
288
+
valrealHash=hash(entry.get)
300
289
assert(cachedHash == realHash, s"for $entry cached hash was $cachedHash but should have been $realHash")
301
-
valcomputedBucket=bucketFor(realHash)
290
+
valcomputedBucket=index(realHash)
302
291
assert(computedBucket == bucket, s"for $entry the computed bucket was $computedBucket but should have been $bucket")
303
292
304
293
entry = entry.tail
@@ -344,11 +333,6 @@ object WeakHashSet {
344
333
* A single entry in a WeakHashSet. It's a WeakReference plus a cached hash code and
345
334
* a link to the next Entry in the same bucket
346
335
*/
347
-
privateclassEntry[A](@constructorOnly element: A, valhash:Int, vartail:Entry[A], @constructorOnly queue: ReferenceQueue[A]) extendsWeakReference[A](element, queue)
348
-
349
-
privatefinalvaldefaultInitialCapacity=16
350
-
privatefinalvaldefaultLoadFactor=.75
336
+
classEntry[A](@constructorOnly element: A, valhash:Int, vartail:Entry[A], @constructorOnly queue: ReferenceQueue[A]) extendsWeakReference[A](element, queue)
0 commit comments