1 Star 0 Fork 0

zhangyc/goben

加入 Gitee
与超过 1200万 开发者一起发现、参与优秀开源项目,私有仓库也完全免费 :)
免费加入
文件
克隆/下载
matchlen_generic.go 547 Bytes
一键复制 编辑 原始数据 按行查看 历史
zhangyc 提交于 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

搜索帮助