MCPcopy Create free account
hub / github.com/imroc/req / Hash

Function Hash

internal/bisect/bisect.go:627–695  ·  view source on GitHub ↗

Hash computes a hash of the data arguments, each of which must be of type string, byte, int, uint, int32, uint32, int64, uint64, uintptr, or a slice of one of those types.

(data ...any)

Source from the content-addressed store, hash-verified

625// Hash computes a hash of the data arguments,
626// each of which must be of type string, byte, int, uint, int32, uint32, int64, uint64, uintptr, or a slice of one of those types.
627func Hash(data ...any) uint64 {
628 h := offset64
629 for _, v := range data {
630 switch v := v.(type) {
631 default:
632 // Note: Not printing the type, because reflect.ValueOf(v)
633 // would make the interfaces prepared by the caller escape
634 // and therefore allocate. This way, Hash(file, line) runs
635 // without any allocation. It should be clear from the
636 // source code calling Hash what the bad argument was.
637 panic("bisect.Hash: unexpected argument type")
638 case string:
639 h = fnvString(h, v)
640 case byte:
641 h = fnv(h, v)
642 case int:
643 h = fnvUint64(h, uint64(v))
644 case uint:
645 h = fnvUint64(h, uint64(v))
646 case int32:
647 h = fnvUint32(h, uint32(v))
648 case uint32:
649 h = fnvUint32(h, v)
650 case int64:
651 h = fnvUint64(h, uint64(v))
652 case uint64:
653 h = fnvUint64(h, v)
654 case uintptr:
655 h = fnvUint64(h, uint64(v))
656 case []string:
657 for _, x := range v {
658 h = fnvString(h, x)
659 }
660 case []byte:
661 for _, x := range v {
662 h = fnv(h, x)
663 }
664 case []int:
665 for _, x := range v {
666 h = fnvUint64(h, uint64(x))
667 }
668 case []uint:
669 for _, x := range v {
670 h = fnvUint64(h, uint64(x))
671 }
672 case []int32:
673 for _, x := range v {
674 h = fnvUint32(h, uint32(x))
675 }
676 case []uint32:
677 for _, x := range v {
678 h = fnvUint32(h, x)
679 }
680 case []int64:
681 for _, x := range v {
682 h = fnvUint64(h, uint64(x))
683 }
684 case []uint64:

Callers 2

fileLineMethod · 0.85
stackMethod · 0.85

Calls 4

fnvStringFunction · 0.85
fnvFunction · 0.85
fnvUint64Function · 0.85
fnvUint32Function · 0.85

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…