1 Star 0 Fork 0

zhangyc / goben

Create your Gitee Account
Explore and code with more than 14 million developers,Free private repositories !:)
Sign up
文件
Clone or Download
matchlen_generic.go 547 Bytes
Copy Edit Raw Blame History
zhangyc authored 2025-05-02 23:10 +08:00 . 优化上传功能,新增常见的工具类
// Copyright 2019+ Klaus Post. All rights reserved.
// License information can be found in the LICENSE file.
package flate
import (
"math/bits"
)
// 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) {
left := len(a)
for left >= 8 {
diff := Load64(a, n) ^ 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] {
break
}
n++
}
return n
}
Loading...
马建仓 AI 助手
尝试更多
代码解读
代码找茬
代码优化
Go
1
https://gitee.com/zhangycsz/goben.git
git@gitee.com:zhangycsz/goben.git
zhangycsz
goben
goben
eaa46e8cfe69

Search