mirror of
https://github.com/ethereum/go-ethereum.git
synced 2026-08-19 18:32:23 +00:00
prealloc capacity for map and slice
This commit is contained in:
parent
45a9ef00e9
commit
186592c444
2 changed files with 2 additions and 2 deletions
|
|
@ -224,7 +224,7 @@ func (t *StateTrie) GetKey(shaKey []byte) []byte {
|
|||
func (t *StateTrie) Commit(collectLeaf bool) (common.Hash, *trienode.NodeSet, error) {
|
||||
// Write all the pre-images to the actual disk database
|
||||
if len(t.getSecKeyCache()) > 0 {
|
||||
preimages := make(map[common.Hash][]byte)
|
||||
preimages := make(map[common.Hash][]byte, len(t.secKeyCache))
|
||||
for hk, key := range t.secKeyCache {
|
||||
preimages[common.BytesToHash([]byte(hk))] = key
|
||||
}
|
||||
|
|
|
|||
|
|
@ -186,7 +186,7 @@ func (set *MergedNodeSet) Merge(other *NodeSet) error {
|
|||
|
||||
// Flatten returns a two-dimensional map for internal nodes.
|
||||
func (set *MergedNodeSet) Flatten() map[common.Hash]map[string]*Node {
|
||||
nodes := make(map[common.Hash]map[string]*Node)
|
||||
nodes := make(map[common.Hash]map[string]*Node, len(set.Sets))
|
||||
for owner, set := range set.Sets {
|
||||
nodes[owner] = set.Nodes
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in a new issue