-
Notifications
You must be signed in to change notification settings - Fork 1.1k
Some improvements to util.HashSet and HashMap #9865
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
Allow to record total sizes of collections on which some selected operation is performed. # Conflicts: # compiler/src/dotty/tools/dotc/transform/Instrumentation.scala
See scala#9748 for why this is necessary
When tranisitioning from dense to hashing, we grow the table more than usual since otherwise we'd have to grow it again at the very next addEntry. The condition for this was wrong for HashMaps.
Make criterion when to fill a hole in a HashMap or HashSet remove more robust. The old criterion relied on fill factor always being less than 0.5. The new criterion works for arbitrary fill factors.
The code was taken from scala.collection.mutable.AnyRefMap
f9b0ab4
to
daf6db7
Compare
test performance please |
performance test scheduled: 2 job(s) in queue, 1 running. |
Performance test finished successfully: Visit http://dotty-bench.epfl.ch/9865/ to see the changes. Benchmarks is based on merging with master (85d1322) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM
@@ -156,7 +158,7 @@ abstract class GenericHashMap[Key, Value] | |||
protected def growTable(): Unit = | |||
val oldTable = table | |||
val newLength = | |||
if oldTable.length == DenseLimit then DenseLimit * 2 * roundToPower(capacityMultiple) | |||
if table.length == DenseLimit * 2 then table.length * roundToPower(capacityMultiple) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I don't quite understand why we need the if
here, instead of simply growing the table, since all calls to growTable
is guarded by if used > limit
. Is it to just create a larger array at the size DenseLimit * 2
(instead of simply doubling the size)?
Meanwhile, if we change the code here, do we need similar changes in HashSet.growTable
?
No description provided.