optimize upsidedown mergeOldAndNew existing key maps
The optimization is to provide a better initial size to the map constructor and to use a 0-byte-sized struct{} as the map values.
This commit is contained in:
parent
c2bafa2a51
commit
40780254ae
@ -502,14 +502,18 @@ func (udc *UpsideDownCouch) mergeOldAndNew(backIndexRow *BackIndexRow, rows []in
|
|||||||
updateRows = make([]UpsideDownCouchRow, 0, len(rows))
|
updateRows = make([]UpsideDownCouchRow, 0, len(rows))
|
||||||
deleteRows = make([]UpsideDownCouchRow, 0, len(rows))
|
deleteRows = make([]UpsideDownCouchRow, 0, len(rows))
|
||||||
|
|
||||||
existingTermKeys := make(map[string]bool)
|
var mark struct{}
|
||||||
for _, key := range backIndexRow.AllTermKeys() {
|
|
||||||
existingTermKeys[string(key)] = true
|
backIndexTermKeys := backIndexRow.AllTermKeys()
|
||||||
|
existingTermKeys := make(map[string]struct{}, len(backIndexTermKeys))
|
||||||
|
for _, key := range backIndexTermKeys {
|
||||||
|
existingTermKeys[string(key)] = mark
|
||||||
}
|
}
|
||||||
|
|
||||||
existingStoredKeys := make(map[string]bool)
|
backIndexStoredKeys := backIndexRow.AllStoredKeys()
|
||||||
for _, key := range backIndexRow.AllStoredKeys() {
|
existingStoredKeys := make(map[string]struct{}, len(backIndexStoredKeys))
|
||||||
existingStoredKeys[string(key)] = true
|
for _, key := range backIndexStoredKeys {
|
||||||
|
existingStoredKeys[string(key)] = mark
|
||||||
}
|
}
|
||||||
|
|
||||||
keyBuf := GetRowBuffer()
|
keyBuf := GetRowBuffer()
|
||||||
|
Loading…
Reference in New Issue
Block a user