From e5810db4e2a3341bbf67a21b8635028b08aba79c Mon Sep 17 00:00:00 2001 From: Dmitry Olshansky Date: Fri, 8 Mar 2013 14:15:40 +0400 Subject: [PATCH] actually use the power-of-two assumption, brings it on par with load factor of 0.5 --- std/d/lexer.d | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/std/d/lexer.d b/std/d/lexer.d index 80e6050..ccf47b9 100644 --- a/std/d/lexer.d +++ b/std/d/lexer.d @@ -3019,7 +3019,7 @@ struct StringCache && is(Unqual!(ElementType!R) : const(ubyte))) { uint h = hash(range); - uint bucket = h % index.length; + uint bucket = h & (index.length-1); Slot *s = index[bucket]; if(s == null) { @@ -3150,7 +3150,7 @@ private: Slot*[] index; size_t uniqueSlots; - enum loadQuot = 1, loadDenom = 3; + enum loadQuot = 1, loadDenom = 2; // leave some slack for alloctors/GC meta-data enum chunkSize = 16*1024 - size_t.sizeof*8;