Skip to content

Commit 8113165

Browse files
committed
address review comments
1 parent a813f2f commit 8113165

File tree

2 files changed

+4
-5
lines changed

2 files changed

+4
-5
lines changed

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

+1-1
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ object EqHashSet:
1515
* initial size of the table will be the smallest power of two
1616
* that is equal or greater than the given `initialCapacity`.
1717
* Minimum value is 4.
18-
* @param capacityMultiple The minimum multiple of capacity relative to used elements.
18+
* @param capacityMultiple The minimum multiple of capacity relative to used elements.
1919
* The hash table will be re-sized once the number of elements
2020
* multiplied by capacityMultiple exceeds the current size of the hash table.
2121
* However, a table of size up to DenseLimit will be re-sized only

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

+3-4
Original file line numberDiff line numberDiff line change
@@ -36,8 +36,7 @@ abstract class GenericHashSet[T](initialCapacity: Int = 8, capacityMultiple: Int
3636

3737
private def roundToPower(n: Int) =
3838
if n < 4 then 4
39-
else if Integer.bitCount(n) == 1 then n
40-
else 1 << (32 - Integer.numberOfLeadingZeros(n))
39+
else 1 << (32 - Integer.numberOfLeadingZeros(n - 1))
4140

4241
def clear(resetToInitial: Boolean): Unit =
4342
used = 0
@@ -49,10 +48,10 @@ abstract class GenericHashSet[T](initialCapacity: Int = 8, capacityMultiple: Int
4948

5049
protected def isDense = limit < DenseLimit
5150

52-
/** Hashcode, by default a processed `x.hashCode`, can be overridden */
51+
/** Hashcode, to be implemented in subclass */
5352
protected def hash(key: T): Int
5453

55-
/** Hashcode, by default `equals`, can be overridden */
54+
/** Equality, to be implemented in subclass */
5655
protected def isEqual(x: T, y: T): Boolean
5756

5857
/** Turn hashcode `x` into a table index */

0 commit comments

Comments
 (0)