eth/protocols/snap: optimize incHash (#32748)

This commit is contained in:
cui 2025-10-10 13:48:25 +08:00 committed by GitHub
parent 4d6d5a3abf
commit ed264a1f19
No known key found for this signature in database
GPG key ID: B5690EEEBB952194

View file

@ -74,8 +74,11 @@ func (r *hashRange) End() common.Hash {
// incHash returns the next hash, in lexicographical order (a.k.a plus one) // incHash returns the next hash, in lexicographical order (a.k.a plus one)
func incHash(h common.Hash) common.Hash { func incHash(h common.Hash) common.Hash {
var a uint256.Int for i := len(h) - 1; i >= 0; i-- {
a.SetBytes32(h[:]) h[i]++
a.AddUint64(&a, 1) if h[i] != 0 {
return common.Hash(a.Bytes32()) break
}
}
return h
} }