// AddString32 adds the hash of s to the precomputed hash value h.
194600
func AddString32(h uint32, s string) uint32 {
	i := 0
	n := (len(s) / 8) * 8

	for i != n {
		h = (h ^ uint32(s[i])) * prime32
		h = (h ^ uint32(s[i+1])) * prime32
		h = (h ^ uint32(s[i+2])) * prime32
		h = (h ^ uint32(s[i+3])) * prime32
		h = (h ^ uint32(s[i+4])) * prime32
		h = (h ^ uint32(s[i+5])) * prime32
		h = (h ^ uint32(s[i+6])) * prime32
		h = (h ^ uint32(s[i+7])) * prime32
		i += 8
	}

	for _, c := range s[i:] {
		h = (h ^ uint32(c)) * prime32
	}

	return h
}
486358
func HashSimpleBase32(input, salt []byte, trim bool) string {
	if trim {
		return strings.Trim(base32.StdEncoding.EncodeToString(HashSimple(input, salt)), "=")
	}
	return base32.StdEncoding.EncodeToString(HashSimple(input, salt))
}
558257
func (enc *Encoder) AddUint32Key(key string, v uint32) {
	enc.Uint64Key(key, uint64(v))
}
767072
func StringToInt32(from string) (int32, error) {
	val, err := strconv.ParseInt(from, DefeultNumericBase, 32)
	return int32(val), err
}
543443
func (h *Hash) IsHash32() bool {
	_, ok := h.Hash.(hash.Hash32)
	return ok
}
904193
func HashUint32(f func() hash.Hash32) func(uint32) uint32 {
	return func(u uint32) uint32 {
		b := [4]byte{}
		binary.BigEndian.PutUint32(b[:], u)
		h := f()
		h.Write(b[:])
		return h.Sum32()
	}
}
995917
func addUint32(code []byte, x uint32, min int) []byte {
	end := len(code) + min
	for x >= 0x80 {
		code = append(code, byte(x)|0x80)
		x >>= 7
	}
	code = append(code, byte(x))
	// Pad the operand with NOPs to exactly min bytes.
	for len(code) < end {
		code = append(code, byte(NOP))
	}
	return code
}
198265
func (b *Builder) addString(v string) {
	strLen := uint(len(v))
	if strLen > 126 {
		// long string
		dst := b.buf.Grow(1 + 8 + strLen)
		dst[0] = 0xbf
		setLength(dst[1:], ValueLength(strLen), 8) // string length
		copy(dst[9:], v)                           // string data
	} else {
		dst := b.buf.Grow(1 + strLen)
		dst[0] = byte(0x40 + strLen) // short string (with length)
		copy(dst[1:], v)             // string data
	}
}
507232
func AddString64(h uint64, s string) uint64 {
	/*
		This is an unrolled version of this algorithm:

		for _, c := range s {
			h = (h ^ uint64(c)) * prime64
		}

		It seems to be ~1.5x faster than the simple loop in BenchmarkHash64:

		- BenchmarkHash64/hash_function-4   30000000   56.1 ns/op   642.15 MB/s   0 B/op   0 allocs/op
		- BenchmarkHash64/hash_function-4   50000000   38.6 ns/op   932.35 MB/s   0 B/op   0 allocs/op

	*/

	i := 0
	n := (len(s) / 8) * 8

	for i != n {
		h = (h ^ uint64(s[i])) * prime64
		h = (h ^ uint64(s[i+1])) * prime64
		h = (h ^ uint64(s[i+2])) * prime64
		h = (h ^ uint64(s[i+3])) * prime64
		h = (h ^ uint64(s[i+4])) * prime64
		h = (h ^ uint64(s[i+5])) * prime64
		h = (h ^ uint64(s[i+6])) * prime64
		h = (h ^ uint64(s[i+7])) * prime64
		i += 8
	}

	for _, c := range s[i:] {
		h = (h ^ uint64(c)) * prime64
	}

	return h
}
966181
func (d *DiskEditValue) AddSSHKeys(keyID string) {
	if d.SSHKeys == nil {
		d.SSHKeys = []*SSHKey{}
	}
	d.SSHKeys = append(d.SSHKeys, &SSHKey{Resource: NewResourceByStringID(keyID)})
}
506722
func (hl *hashList) Add(file string) hash.Hash {
	if existing, ok := hl.hashes[file]; ok {
		return existing
	}

	h := sha256.New()
	hl.hashes[file] = h
	return h
}
185831
func addKeyString(xu *xgbutil.XUtil, callback xgbutil.CallbackKey,
	evtype int, win xproto.Window, keyStr string, grab bool) {

	xu.KeybindsLck.Lock()
	defer xu.KeybindsLck.Unlock()

	k := xgbutil.KeyString{
		Str:      keyStr,
		Callback: callback,
		Evtype:   evtype,
		Win:      win,
		Grab:     grab,
	}
	xu.Keystrings = append(xu.Keystrings, k)
}
1153900
func (c Context) Uints32(key string, i []uint32) Context {
	c.l.context = enc.AppendUints32(enc.AppendKey(c.l.context, key), i)
	return c
}
434080
func Hash(s string) string {
	return fmt.Sprintf("%x", md5.Sum([]byte(s)))
}
151395
func (h *HLL) AddWithHasher(value string, hasher func(string) uint64) {
	hash := hasher(value)
	h.AddHash(hash)
}
810341
func (enc *Encoder) AddFloat32Key(key string, v float32) {
	enc.Float32Key(key, v)
}
448730
func (h *HyperLogLog) Add(item Hash32) {
	x := item.Sum32()
	i := eb32(x, 32, 32-h.p) // {x31,...,x32-p}
	w := x<<h.p | 1<<(h.p-1) // {x32-p,...,x0}

	zeroBits := clz32(w) + 1
	if zeroBits > h.reg[i] {
		h.reg[i] = zeroBits
	}
}