github.com/coyove/sdss@v0.0.0-20231129015646-c2ec58cca6a2/contrib/plru/hash.go (about)

     1  package plru
     2  
     3  import _ "unsafe"
     4  
     5  //go:linkname stringHash runtime.stringHash
     6  func stringHash(s string, seed uintptr) uintptr
     7  
     8  //go:linkname int64Hash runtime.int64Hash
     9  func int64Hash(v uint64, seed uintptr) uintptr
    10  
    11  var Hash = struct {
    12  	Str    func(v string) uint64
    13  	Int    func(v int) uint64
    14  	Int64  func(v int64) uint64
    15  	Int64a func(v int64) uint64
    16  	Uint32 func(v uint32) uint64
    17  	Uint64 func(v uint64) uint64
    18  }{
    19  	func(v string) uint64 { return uint64(stringHash(v, 0)) },
    20  	func(v int) uint64 { return uint64(int64Hash(uint64(v), 0)) },
    21  	func(v int64) uint64 { return uint64(int64Hash(uint64(v), 0)) },
    22  	func(v int64) uint64 { return uint64(v) },
    23  	func(v uint32) uint64 { return uint64(int64Hash(uint64(v), 0)) },
    24  	func(v uint64) uint64 { return uint64(int64Hash(uint64(v), 0)) },
    25  }