Skip to content

Commit cc70a2e

Browse files
committed
add HashTrieMap
1 parent 680730f commit cc70a2e

File tree

8 files changed

+1684
-20
lines changed

8 files changed

+1684
-20
lines changed

hash/maphash/comparable_go120.go

+2-5
Original file line numberDiff line numberDiff line change
@@ -4,13 +4,10 @@ package maphash
44

55
import (
66
"github.com/metacubex/backport-std/internal/abi"
7+
"github.com/metacubex/backport-std/internal/goarch"
78
"unsafe"
89
)
910

10-
// ptrSize is the size of a pointer in bytes - unsafe.Sizeof(uintptr(0)) but as an ideal constant.
11-
// It is also the size of the machine's native word size (that is, 4 on 32-bit systems, 8 on 64-bit).
12-
const ptrSize = 4 << (^uintptr(0) >> 63)
13-
1411
func Comparable[T comparable](s Seed, v T) uint64 {
1512
return comparableHash(*(*seedTyp)(unsafe.Pointer(&s)), v)
1613
}
@@ -28,7 +25,7 @@ func comparableHash[T comparable](seed seedTyp, v T) uint64 {
2825

2926
p := abi.Escape(unsafe.Pointer(&v))
3027

31-
if ptrSize == 8 {
28+
if goarch.PtrSize == 8 {
3229
return uint64(hasher(p, uintptr(s)))
3330
}
3431
lo := hasher(p, uintptr(s))

internal/goarch/ptrsize.go

+5
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
package goarch
2+
3+
// PtrSize is the size of a pointer in bytes - unsafe.Sizeof(uintptr(0)) but as an ideal constant.
4+
// It is also the size of the machine's native word size (that is, 4 on 32-bit systems, 8 on 64-bit).
5+
const PtrSize = 4 << (^uintptr(0) >> 63)

0 commit comments

Comments
 (0)