diff options
author | Ethan Buchman <ethan@coinculture.info> | 2015-08-06 15:11:10 +0800 |
---|---|---|
committer | Ethan Buchman <ethan@coinculture.info> | 2015-08-06 15:17:59 +0800 |
commit | c1d516546d221de898ddeb12a77477d992d125df (patch) | |
tree | 9f2208127d4325546ac524b9e56ae8cd525abb92 /trie/trie.go | |
parent | 98100f472c3bee473ea32044e47e82835b9cfadb (diff) | |
download | dexon-c1d516546d221de898ddeb12a77477d992d125df.tar dexon-c1d516546d221de898ddeb12a77477d992d125df.tar.gz dexon-c1d516546d221de898ddeb12a77477d992d125df.tar.bz2 dexon-c1d516546d221de898ddeb12a77477d992d125df.tar.lz dexon-c1d516546d221de898ddeb12a77477d992d125df.tar.xz dexon-c1d516546d221de898ddeb12a77477d992d125df.tar.zst dexon-c1d516546d221de898ddeb12a77477d992d125df.zip |
faster hex-prefix codec and string -> []byte
Diffstat (limited to 'trie/trie.go')
-rw-r--r-- | trie/trie.go | 10 |
1 files changed, 5 insertions, 5 deletions
diff --git a/trie/trie.go b/trie/trie.go index e7ee86402..abf48a850 100644 --- a/trie/trie.go +++ b/trie/trie.go @@ -69,7 +69,7 @@ func (self *Trie) Iterator() *Iterator { func (self *Trie) Copy() *Trie { cpy := make([]byte, 32) - copy(cpy, self.roothash) + copy(cpy, self.roothash) // NOTE: cpy isn't being used anywhere? trie := New(nil, nil) trie.cache = self.cache.Copy() if self.root != nil { @@ -131,7 +131,7 @@ func (self *Trie) Update(key, value []byte) Node { self.mu.Lock() defer self.mu.Unlock() - k := CompactHexDecode(string(key)) + k := CompactHexDecode(key) if len(value) != 0 { node := NewValueNode(self, value) @@ -149,7 +149,7 @@ func (self *Trie) Get(key []byte) []byte { self.mu.Lock() defer self.mu.Unlock() - k := CompactHexDecode(string(key)) + k := CompactHexDecode(key) n := self.get(self.root, k) if n != nil { @@ -164,7 +164,7 @@ func (self *Trie) Delete(key []byte) Node { self.mu.Lock() defer self.mu.Unlock() - k := CompactHexDecode(string(key)) + k := CompactHexDecode(key) self.root = self.delete(self.root, k) return self.root @@ -336,7 +336,7 @@ func (self *Trie) mknode(value *common.Value) Node { case 2: // A value node may consists of 2 bytes. if value.Get(0).Len() != 0 { - key := CompactDecode(string(value.Get(0).Bytes())) + key := CompactDecode(value.Get(0).Bytes()) if key[len(key)-1] == 16 { return NewShortNode(self, key, NewValueNode(self, value.Get(1).Bytes())) } else { |