mirror of
https://github.com/ethereum/go-ethereum.git
synced 2026-08-19 18:32:23 +00:00
preallocated capacity for map's certain usege of memory
This commit is contained in:
parent
9f96e07c1c
commit
1d06df1c1f
4 changed files with 5 additions and 5 deletions
|
|
@ -624,7 +624,7 @@ func decodePrealloc(data string) types.GenesisAlloc {
|
||||||
acc.Nonce = account.Misc.Nonce
|
acc.Nonce = account.Misc.Nonce
|
||||||
acc.Code = account.Misc.Code
|
acc.Code = account.Misc.Code
|
||||||
|
|
||||||
acc.Storage = make(map[common.Hash]common.Hash)
|
acc.Storage = make(map[common.Hash]common.Hash, len(account.Misc.Slots))
|
||||||
for _, slot := range account.Misc.Slots {
|
for _, slot := range account.Misc.Slots {
|
||||||
acc.Storage[slot.Key] = slot.Val
|
acc.Storage[slot.Key] = slot.Val
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -436,7 +436,7 @@ type virtualHostHandler struct {
|
||||||
}
|
}
|
||||||
|
|
||||||
func newVHostHandler(vhosts []string, next http.Handler) http.Handler {
|
func newVHostHandler(vhosts []string, next http.Handler) http.Handler {
|
||||||
vhostMap := make(map[string]struct{})
|
vhostMap := make(map[string]struct{}, len(vhosts))
|
||||||
for _, allowedHost := range vhosts {
|
for _, allowedHost := range vhosts {
|
||||||
vhostMap[strings.ToLower(allowedHost)] = struct{}{}
|
vhostMap[strings.ToLower(allowedHost)] = struct{}{}
|
||||||
}
|
}
|
||||||
|
|
@ -636,7 +636,7 @@ func RegisterApis(apis []rpc.API, modules []string, srv *rpc.Server) error {
|
||||||
log.Error("Unavailable modules in HTTP API list", "unavailable", bad, "available", available)
|
log.Error("Unavailable modules in HTTP API list", "unavailable", bad, "available", available)
|
||||||
}
|
}
|
||||||
// Generate the allow list based on the allowed modules
|
// Generate the allow list based on the allowed modules
|
||||||
allowList := make(map[string]bool)
|
allowList := make(map[string]bool, len(modules))
|
||||||
for _, module := range modules {
|
for _, module := range modules {
|
||||||
allowList[module] = true
|
allowList[module] = true
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -190,7 +190,7 @@ func (s *RPCService) Modules() map[string]string {
|
||||||
s.server.services.mu.Lock()
|
s.server.services.mu.Lock()
|
||||||
defer s.server.services.mu.Unlock()
|
defer s.server.services.mu.Unlock()
|
||||||
|
|
||||||
modules := make(map[string]string)
|
modules := make(map[string]string, len(s.server.services.services))
|
||||||
for name := range s.server.services.services {
|
for name := range s.server.services.services {
|
||||||
modules[name] = "1.0"
|
modules[name] = "1.0"
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -90,7 +90,7 @@ func (b *nodebuffer) commit(nodes map[common.Hash]map[string]*trienode.Node) *no
|
||||||
// The nodes belong to original diff layer are still accessible even
|
// The nodes belong to original diff layer are still accessible even
|
||||||
// after merging, thus the ownership of nodes map should still belong
|
// after merging, thus the ownership of nodes map should still belong
|
||||||
// to original layer and any mutation on it should be prevented.
|
// to original layer and any mutation on it should be prevented.
|
||||||
current = make(map[string]*trienode.Node)
|
current = make(map[string]*trienode.Node, len(subset))
|
||||||
for path, n := range subset {
|
for path, n := range subset {
|
||||||
current[path] = n
|
current[path] = n
|
||||||
delta += int64(len(n.Blob) + len(path))
|
delta += int64(len(n.Blob) + len(path))
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue