...
1
2
3
4
5 package sync
6
7 import (
8 "internal/abi"
9 "unsafe"
10 )
11
12
13
14 func NewBadHashTrieMap[K, V comparable]() *HashTrieMap[K, V] {
15
16
17 var m HashTrieMap[K, V]
18 m.init()
19 m.keyHash = func(_ unsafe.Pointer, _ uintptr) uintptr {
20 return 0
21 }
22 return &m
23 }
24
25
26
27 func NewTruncHashTrieMap[K, V comparable]() *HashTrieMap[K, V] {
28
29
30 var m HashTrieMap[K, V]
31 var mx map[string]int
32 mapType := abi.TypeOf(mx).MapType()
33 hasher := mapType.Hasher
34 m.keyHash = func(p unsafe.Pointer, n uintptr) uintptr {
35 return hasher(p, n) & ((uintptr(1) << 4) - 1)
36 }
37 return &m
38 }
39
View as plain text