diff options
author | Sarlor <kinsleer@outlook.com> | 2018-06-07 16:48:36 +0800 |
---|---|---|
committer | Péter Szilágyi <peterke@gmail.com> | 2018-06-07 16:48:36 +0800 |
commit | ea06da089264508601a9f967160b8c7f335071fa (patch) | |
tree | aa6ece6c5d2a68be2be132db90bfc3701e802fdb /trie | |
parent | feb6620c346b62d938cfde4bd6677a1c680e29b2 (diff) | |
download | dexon-ea06da089264508601a9f967160b8c7f335071fa.tar dexon-ea06da089264508601a9f967160b8c7f335071fa.tar.gz dexon-ea06da089264508601a9f967160b8c7f335071fa.tar.bz2 dexon-ea06da089264508601a9f967160b8c7f335071fa.tar.lz dexon-ea06da089264508601a9f967160b8c7f335071fa.tar.xz dexon-ea06da089264508601a9f967160b8c7f335071fa.tar.zst dexon-ea06da089264508601a9f967160b8c7f335071fa.zip |
trie: avoid unnecessary slicing on shortnode decoding (#16917)
optimization code
Diffstat (limited to 'trie')
-rw-r--r-- | trie/encoding.go | 7 |
1 files changed, 3 insertions, 4 deletions
diff --git a/trie/encoding.go b/trie/encoding.go index 221fa6d3a..5f120de63 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 |