Skip to content

Commit

Permalink
trie: avoid unnecessary slicing on shortnode decoding (#16917)
Browse files Browse the repository at this point in the history
optimization code
  • Loading branch information
Sarlor authored and karalabe committed Jun 7, 2018
1 parent feb6620 commit ea06da0
Showing 1 changed file with 3 additions and 4 deletions.
7 changes: 3 additions & 4 deletions trie/encoding.go
Original file line number Diff line number Diff line change
Expand Up @@ -53,10 +53,9 @@ func hexToCompact(hex []byte) []byte {

func compactToHex(compact []byte) []byte {
base := keybytesToHex(compact)
base = base[:len(base)-1]
// apply terminator flag
if base[0] >= 2 {
base = append(base, 16)
// delete terminator flag
if base[0] < 2 {
base = base[:len(base)-1]
}
// apply odd flag
chop := 2 - base[0]&1
Expand Down

0 comments on commit ea06da0

Please sign in to comment.