File: keyset_default.go

package info (click to toggle)
golang-github-segmentio-asm 1.2.0%2Bgit20231107.1cfacc8-1
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid
  • size: 932 kB
  • sloc: asm: 6,093; makefile: 32
file content (19 lines) | stat: -rw-r--r-- 367 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
//go:build purego || !(amd64 || arm64)
// +build purego !amd64,!arm64

package keyset

func Lookup(keyset []byte, key []byte) int {
	if len(key) > 16 {
		return len(keyset) / 16
	}
	var padded [16]byte
	copy(padded[:], key)

	for i := 0; i < len(keyset); i += 16 {
		if string(padded[:]) == string(keyset[i:i+16]) {
			return i / 16
		}
	}
	return len(keyset) / 16
}