forked from TrueCloudLab/neoneo-go
storage: use map size hints to optimize subsequent persist()
We're likely to have something comparable to the current changeset in the subsequent one. If it's bigger, no big deal, it'll be reallocated, if it's smaller, no big deal, the next one will be preallocated smaller.
This commit is contained in:
parent
428ba48444
commit
9576e10d04
1 changed files with 2 additions and 2 deletions
|
@ -252,8 +252,8 @@ func (s *MemCachedStore) persist(isSync bool) (int, error) {
|
|||
// unprotected while writes are handled by s proper.
|
||||
var tempstore = &MemCachedStore{MemoryStore: MemoryStore{mem: s.mem, del: s.del}, ps: s.ps}
|
||||
s.ps = tempstore
|
||||
s.mem = make(map[string][]byte)
|
||||
s.del = make(map[string]bool)
|
||||
s.mem = make(map[string][]byte, len(s.mem))
|
||||
s.del = make(map[string]bool, len(s.del))
|
||||
if !isSync {
|
||||
s.mut.Unlock()
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue