matchLen returns the maximum common prefix length of a and b. a must be the shortest of the two.
(a, b []byte)
| 14 | // matchLen returns the maximum common prefix length of a and b. |
| 15 | // a must be the shortest of the two. |
| 16 | func 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 | } |
nothing calls this directly
no test coverage detected
searching dependent graphs…