@@ -32,7 +32,6 @@ import (
32
32
"unsafe"
33
33
34
34
"github.com/Workiva/go-datastructures/list"
35
- "github.com/Workiva/go-datastructures/queue"
36
35
)
37
36
38
37
const (
@@ -41,9 +40,6 @@ const (
41
40
42
41
// exp2 is 2^w, which is the hashcode space.
43
42
exp2 = 32
44
-
45
- // hasherPoolSize is the number of hashers to buffer.
46
- hasherPoolSize = 16
47
43
)
48
44
49
45
// HashFactory returns a new Hash32 used to hash keys.
@@ -59,7 +55,6 @@ type Ctrie struct {
59
55
root * iNode
60
56
readOnly bool
61
57
hashFactory HashFactory
62
- hasherPool * queue.RingBuffer
63
58
}
64
59
65
60
// generation demarcates Ctrie snapshots. We use a heap-allocated reference
@@ -280,14 +275,9 @@ func New(hashFactory HashFactory) *Ctrie {
280
275
}
281
276
282
277
func newCtrie (root * iNode , hashFactory HashFactory , readOnly bool ) * Ctrie {
283
- hasherPool := queue .NewRingBuffer (hasherPoolSize )
284
- for i := 0 ; i < hasherPoolSize ; i ++ {
285
- hasherPool .Put (hashFactory ())
286
- }
287
278
return & Ctrie {
288
279
root : root ,
289
280
hashFactory : hashFactory ,
290
- hasherPool : hasherPool ,
291
281
readOnly : readOnly ,
292
282
}
293
283
}
@@ -451,13 +441,9 @@ func (c *Ctrie) remove(entry *Entry) (interface{}, bool) {
451
441
}
452
442
453
443
func (c * Ctrie ) hash (k []byte ) uint32 {
454
- hasher , _ := c .hasherPool .Get ()
455
- h := hasher .(hash.Hash32 )
456
- h .Write (k )
457
- hash := h .Sum32 ()
458
- h .Reset ()
459
- c .hasherPool .Put (h )
460
- return hash
444
+ hasher := c .hashFactory ()
445
+ hasher .Write (k )
446
+ return hasher .Sum32 ()
461
447
}
462
448
463
449
// iinsert attempts to insert the entry into the Ctrie. If false is returned,
0 commit comments