Skip to content

Commit ea06da0

Browse files
Sarlorkaralabe
Sarlor
authored andcommitted
trie: avoid unnecessary slicing on shortnode decoding (#16917)
optimization code
1 parent feb6620 commit ea06da0

File tree

1 file changed

+3
-4
lines changed

1 file changed

+3
-4
lines changed

trie/encoding.go

+3-4
Original file line numberDiff line numberDiff line change
@@ -53,10 +53,9 @@ func hexToCompact(hex []byte) []byte {
5353

5454
func compactToHex(compact []byte) []byte {
5555
base := keybytesToHex(compact)
56-
base = base[:len(base)-1]
57-
// apply terminator flag
58-
if base[0] >= 2 {
59-
base = append(base, 16)
56+
// delete terminator flag
57+
if base[0] < 2 {
58+
base = base[:len(base)-1]
6059
}
6160
// apply odd flag
6261
chop := 2 - base[0]&1

0 commit comments

Comments
 (0)