nitlanguage
/
nit.git
/ commitdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
| commitdiff |
tree
raw
|
patch
| inline |
side by side
(parent:
f6b59c3
)
lib/std: better policy for enlarging HashCollection
author
Jean Privat
<jean@pryen.org>
Wed, 6 Aug 2014 19:32:55 +0000
(15:32 -0400)
committer
Jean Privat
<jean@pryen.org>
Thu, 7 Aug 2014 00:01:34 +0000
(20:01 -0400)
Signed-off-by: Jean Privat <jean@pryen.org>
lib/standard/collection/hash_collection.nit
patch
|
blob
|
history
diff --git
a/lib/standard/collection/hash_collection.nit
b/lib/standard/collection/hash_collection.nit
index
c2c8353
..
2def742
100644
(file)
--- a/
lib/standard/collection/hash_collection.nit
+++ b/
lib/standard/collection/hash_collection.nit
@@
-91,9
+91,13
@@
private abstract class HashCollection[K: Object, N: HashNode[Object]]
# Enlarge if needed
var l = _length
_length = l + 1
- l = (l + 5) * 3 / 2
+
+ # Magic values determined empirically
+ # We do not want to enlarge too much
+ # We also want a odd capacity so that the modulo is more distributive
+ l = (l + 5) * 2 + 1
if l >= _capacity then
- enlarge(l * 2)
+ enlarge(l * 3 / 2 + 1)
end
end