MCPcopy
hub / github.com/klauspost/compress / matchLen

Function matchLen

zstd/matchlen_generic.go:16–37  ·  view source on GitHub ↗

matchLen returns the maximum common prefix length of a and b. a must be the shortest of the two.

(a, b []byte)

Source from the content-addressed store, hash-verified

14// matchLen returns the maximum common prefix length of a and b.
15// a must be the shortest of the two.
16func matchLen(a, b []byte) (n int) {
17 left := len(a)
18 for left >= 8 {
19 diff := le.Load64(a, n) ^ le.Load64(b, n)
20 if diff != 0 {
21 return n + bits.TrailingZeros64(diff)>>3
22 }
23 n += 8
24 left -= 8
25 }
26 a = a[n:]
27 b = b[n:]
28
29 for i := range a {
30 if a[i] != b[i] {
31 break
32 }
33 n++
34 }
35 return n
36
37}

Callers

nothing calls this directly

Calls 1

Load64Function · 0.92

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…