aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorSarlor <kinsleer@outlook.com>2018-06-07 16:48:36 +0800
committerPéter Szilágyi <peterke@gmail.com>2018-06-07 16:48:36 +0800
commitea06da089264508601a9f967160b8c7f335071fa (patch)
treeaa6ece6c5d2a68be2be132db90bfc3701e802fdb
parentfeb6620c346b62d938cfde4bd6677a1c680e29b2 (diff)
downloaddexon-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
-rw-r--r--trie/encoding.go7
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