diff options
| author | 2025-03-02 16:42:51 +0100 | |
|---|---|---|
| committer | 2025-03-02 16:42:51 +0100 | |
| commit | 8488ac928651656c6f7bebf5eaabce62c2b9fb66 (patch) | |
| tree | 94357311026e5ed96862a647400375a4543dd815 /vendor/github.com/klauspost/compress/zstd/matchlen_generic.go | |
| parent | [chore] go-swagger -> codeberg (#3856) (diff) | |
| download | gotosocial-8488ac928651656c6f7bebf5eaabce62c2b9fb66.tar.xz | |
[chore] migrate oauth2 -> codeberg (#3857)
Diffstat (limited to 'vendor/github.com/klauspost/compress/zstd/matchlen_generic.go')
| -rw-r--r-- | vendor/github.com/klauspost/compress/zstd/matchlen_generic.go | 11 |
1 files changed, 8 insertions, 3 deletions
diff --git a/vendor/github.com/klauspost/compress/zstd/matchlen_generic.go b/vendor/github.com/klauspost/compress/zstd/matchlen_generic.go index 57b9c31c0..bea1779e9 100644 --- a/vendor/github.com/klauspost/compress/zstd/matchlen_generic.go +++ b/vendor/github.com/klauspost/compress/zstd/matchlen_generic.go @@ -7,20 +7,25 @@ package zstd import ( - "encoding/binary" "math/bits" + + "github.com/klauspost/compress/internal/le" ) // matchLen returns the maximum common prefix length of a and b. // a must be the shortest of the two. func matchLen(a, b []byte) (n int) { - for ; len(a) >= 8 && len(b) >= 8; a, b = a[8:], b[8:] { - diff := binary.LittleEndian.Uint64(a) ^ binary.LittleEndian.Uint64(b) + left := len(a) + for left >= 8 { + diff := le.Load64(a, n) ^ le.Load64(b, n) if diff != 0 { return n + bits.TrailingZeros64(diff)>>3 } n += 8 + left -= 8 } + a = a[n:] + b = b[n:] for i := range a { if a[i] != b[i] { |
