Skip to content

Commit ed264a1

Browse files
authored
eth/protocols/snap: optimize incHash (#32748)
1 parent 4d6d5a3 commit ed264a1

File tree

1 file changed

+7
-4
lines changed

1 file changed

+7
-4
lines changed

eth/protocols/snap/range.go

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -74,8 +74,11 @@ func (r *hashRange) End() common.Hash {
7474

7575
// incHash returns the next hash, in lexicographical order (a.k.a plus one)
7676
func incHash(h common.Hash) common.Hash {
77-
var a uint256.Int
78-
a.SetBytes32(h[:])
79-
a.AddUint64(&a, 1)
80-
return common.Hash(a.Bytes32())
77+
for i := len(h) - 1; i >= 0; i-- {
78+
h[i]++
79+
if h[i] != 0 {
80+
break
81+
}
82+
}
83+
return h
8184
}

0 commit comments

Comments
 (0)