trie: simplify code

This commit is contained in:
cuiweixie 2025-10-20 21:46:49 +08:00
parent b1809d13d1
commit 59654d9c3a
No known key found for this signature in database
GPG key ID: 16DF64EE15E495A3

View file

@ -138,16 +138,13 @@ func decodeNibbles(nibbles []byte, bytes []byte) {
// prefixLen returns the length of the common prefix of a and b.
func prefixLen(a, b []byte) int {
var i, length = 0, len(a)
if len(b) < length {
length = len(b)
}
for ; i < length; i++ {
n := min(len(a), len(b))
for i := range n {
if a[i] != b[i] {
break
return i
}
}
return i
return n
}
// hasTerm returns whether a hex key has the terminator flag.