mirror of
https://github.com/ethereum/go-ethereum.git
synced 2026-08-11 22:43:47 +00:00
trie: reduce allocations in trie hasher
This commit is contained in:
parent
f485e213b6
commit
00ed30e6fc
1 changed files with 6 additions and 2 deletions
|
|
@ -148,7 +148,9 @@ func (h *hasher) shortnodeToHash(n *shortNode, force bool) node {
|
||||||
if len(enc) < 32 && !force {
|
if len(enc) < 32 && !force {
|
||||||
return n // Nodes smaller than 32 bytes are stored inside their parent
|
return n // Nodes smaller than 32 bytes are stored inside their parent
|
||||||
}
|
}
|
||||||
return h.hashData(enc)
|
var hn hashNode
|
||||||
|
h.hashDataTo(hn, enc)
|
||||||
|
return hn
|
||||||
}
|
}
|
||||||
|
|
||||||
// fullnodeToHash is used to create a hashNode from a fullNode, (which
|
// fullnodeToHash is used to create a hashNode from a fullNode, (which
|
||||||
|
|
@ -160,7 +162,9 @@ func (h *hasher) fullnodeToHash(n *fullNode, force bool) node {
|
||||||
if len(enc) < 32 && !force {
|
if len(enc) < 32 && !force {
|
||||||
return n // Nodes smaller than 32 bytes are stored inside their parent
|
return n // Nodes smaller than 32 bytes are stored inside their parent
|
||||||
}
|
}
|
||||||
return h.hashData(enc)
|
var hn hashNode
|
||||||
|
h.hashDataTo(hn, enc)
|
||||||
|
return hn
|
||||||
}
|
}
|
||||||
|
|
||||||
// encodedBytes returns the result of the last encoding operation on h.encbuf.
|
// encodedBytes returns the result of the last encoding operation on h.encbuf.
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue