File: hash.go

package info (click to toggle)
golang-github-evanw-esbuild 0.25.10-1
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid
  • size: 10,184 kB
  • sloc: javascript: 28,602; makefile: 856; sh: 17
file content (14 lines) | stat: -rw-r--r-- 391 bytes parent folder | download | duplicates (3)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
package helpers

// From: http://boost.sourceforge.net/doc/html/boost/hash_combine.html
func HashCombine(seed uint32, hash uint32) uint32 {
	return seed ^ (hash + 0x9e3779b9 + (seed << 6) + (seed >> 2))
}

func HashCombineString(seed uint32, text string) uint32 {
	seed = HashCombine(seed, uint32(len(text)))
	for _, c := range text {
		seed = HashCombine(seed, uint32(c))
	}
	return seed
}