// decodeHashes takes a ThreatEntrySet and returns a list of hashes that should
// be added to the local database.
184763
func decodeHashes(input *pb.ThreatEntrySet) ([]hashPrefix, error) {
	switch input.CompressionType {
	case pb.CompressionType_RAW:
		raw := input.GetRawHashes()
		if raw == nil {
			return nil, errors.New("safebrowsing: nil raw hashes")
		}
		if raw.PrefixSize < minHashPrefixLength || raw.PrefixSize > maxHashPrefixLength {
			return nil, errors.New("safebrowsing: invalid hash prefix length")
		}
		if len(raw.RawHashes)%int(raw.PrefixSize) != 0 {
			return nil, errors.New("safebrowsing: invalid raw hashes")
		}
		hashes := make([]hashPrefix, len(raw.RawHashes)/int(raw.PrefixSize))
		for i := range hashes {
			hashes[i] = hashPrefix(raw.RawHashes[:raw.PrefixSize])
			raw.RawHashes = raw.RawHashes[raw.PrefixSize:]
		}
		return hashes, nil
	case pb.CompressionType_RICE:
		values, err := decodeRiceIntegers(input.GetRiceHashes())
		if err != nil {
			return nil, err
		}
		hashes := make([]hashPrefix, 0, len(values))
		var buf [4]byte
		for _, h := range values {
			binary.LittleEndian.PutUint32(buf[:], h)
			hashes = append(hashes, hashPrefix(buf[:]))
		}
		return hashes, nil
	default:
		return nil, errors.New("safebrowsing: invalid compression type")
	}
}
1132695
func (h *Plus) decodeHash(k uint32) (uint32, uint8) {
	var r uint8
	if k&1 == 1 {
		r = uint8(bextr32(k, 1, 6)) + h.pp - h.p
	} else {
		r = uint8(bits.LeadingZeros32(k<<(32-h.pp+h.p-1)) + 1)
	}
	return h.getIndex(k), r
}
1058754
func (mi *MemoryIndex) Hashes() []plumbing.Hash {
	hashes := make([]plumbing.Hash, 0, len(mi.indexMap))
	for k := range mi.indexMap {
		hashes = append(hashes, k)
	}
	return hashes
}
37141
func (t *ETagConfig) SetHashFunc(hashFunc ETagHashFunc) *ETagConfig {
	t.HashFunc = hashFunc
	return t
}
104487
func unhashList(ksids [][]byte) ([]sqltypes.Value, error) {
	values := make([]sqltypes.Value, 0, len(ksids))
	for _, ksid := range ksids {
		v, err := vunhash(ksid)
		if err != nil {
			return nil, err
		}
		values = append(values, sqltypes.NewUint64(v))
	}
	return values, nil
}
930184
func (s *Shard) SetHashKeyRange(v *HashKeyRange) *Shard {
	s.HashKeyRange = v
	return s
}
240598
func DecodeInts(s string) ([]int, error) {
	xs, err := DecodeUints(s)
	if err != nil {
		return nil, err
	}
	ys := make([]int, len(xs))
	for i, u := range xs {
		if u&1 == 0 {
			ys[i] = int(u >> 1)
		} else {
			ys[i] = -int((u + 1) >> 1)
		}
	}
	return ys, nil
}
893519
func baseHashes(data []byte) [4]uint64 {
	a1 := []byte{1} // to grab another bit of data
	hasher := murmur3.New128()
	hasher.Write(data) // #nosec
	v1, v2 := hasher.Sum128()
	hasher.Write(a1) // #nosec
	v3, v4 := hasher.Sum128()
	return [4]uint64{
		v1, v2, v3, v4,
	}
}
240864
func (h *HashID) DecodeWithError(hash string) ([]int, error) {
	result64, err := h.DecodeInt64WithError(hash)
	if err != nil {
		return nil, err
	}
	result := make([]int, 0, len(result64))
	for _, id := range result64 {
		result = append(result, int(id))
	}
	return result, nil
}
344535
func decodeIndices(input *pb.ThreatEntrySet) ([]int32, error) {
	switch input.CompressionType {
	case pb.CompressionType_RAW:
		raw := input.GetRawIndices()
		if raw == nil {
			return nil, errors.New("safebrowsing: invalid raw indices")
		}
		return raw.Indices, nil
	case pb.CompressionType_RICE:
		values, err := decodeRiceIntegers(input.GetRiceIndices())
		if err != nil {
			return nil, err
		}
		indices := make([]int32, 0, len(values))
		for _, v := range values {
			indices = append(indices, int32(v))
		}
		return indices, nil
	default:
		return nil, errors.New("safebrowsing: invalid compression type")
	}
}
344927
func (fi *fileIndex) Hashes() []plumbing.Hash {
	hashes := make([]plumbing.Hash, fi.fanout[0xff])
	for i := 0; i < int(fi.fanout[0xff]); i++ {
		offset := fi.oidLookupOffset + int64(i)*20
		if n, err := fi.reader.ReadAt(hashes[i][:], offset); err != nil || n < 20 {
			return nil
		}
	}
	return hashes
}
305972
func (h *HashID) DecodeHex(hash string) (string, error) {
	numbers, err := h.DecodeInt64WithError(hash)
	if err != nil {
		return "", err
	}

	const hex = "0123456789abcdef"
	b := make([]byte, len(numbers))
	for i, n := range numbers {
		if n < 0x10 || n > 0x1f {
			return "", errors.New("invalid number")
		}
		b[i] = hex[n-0x10]
	}
	return string(b), nil
}
657592
func MustHashTrytes(t Trytes, rounds ...CurlRounds) Trytes {
	trytes, err := HashTrytes(t, rounds...)
	if err != nil {
		panic(err)
	}
	return trytes
}
1363254
func (d Decoder) DecodeValues(dst interface{}, vs url.Values) error {
	v := reflect.ValueOf(dst)
	return d.decodeNode(v, parseValues(d.d, d.e, vs, canIndexOrdinally(v)))
}
4006
func decodeStructObjectMethods(mrb *Mrb, v *MrbValue) decodeStructGetter {
	return func(key string) (*MrbValue, error) {
		return v.Call(key)
	}
}
773268
func DecodeValues(dst interface{}, vs url.Values) error {
	return NewDecoder(nil).DecodeValues(dst, vs)
}
213381
func (db *RedisDB) hashFields(k string) []string {
	v := db.hashKeys[k]
	r := make([]string, 0, len(v))
	for k := range v {
		r = append(r, k)
	}
	sort.Strings(r)
	return r
}