From ea06da089264508601a9f967160b8c7f335071fa Mon Sep 17 00:00:00 2001 From: Sarlor Date: Thu, 7 Jun 2018 16:48:36 +0800 Subject: [PATCH] trie: avoid unnecessary slicing on shortnode decoding (#16917) optimization code --- trie/encoding.go | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/trie/encoding.go b/trie/encoding.go index 221fa6d3aa..5f120de638 100644 --- a/trie/encoding.go +++ b/trie/encoding.go @@ -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