mirror of https://github.com/golang/go.git
internal/runtime/maps: use matchEmptyOrDeleted instead of matchEmpty
It's a bit more efficient. Change-Id: If813a597516c41fdac6f60e586641d0ee1cde025 Reviewed-on: https://go-review.googlesource.com/c/go/+/623818 Reviewed-by: Michael Pratt <mpratt@google.com> Reviewed-by: Carlos Amedee <carlos@golang.org> LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
This commit is contained in:
parent
900578d09c
commit
378c48e6c7
|
|
@ -554,9 +554,10 @@ func (m *Map) putSlotSmall(typ *abi.SwissMapType, hash uintptr, key unsafe.Point
|
|||
match = match.removeFirst()
|
||||
}
|
||||
|
||||
// No need to look for deleted slots, small maps can't have them (see
|
||||
// deleteSmall).
|
||||
match = g.ctrls().matchEmpty()
|
||||
// There can't be deleted slots, small maps can't have them
|
||||
// (see deleteSmall). Use matchEmptyOrDeleted as it is a bit
|
||||
// more efficient than matchEmpty.
|
||||
match = g.ctrls().matchEmptyOrDeleted()
|
||||
if match == 0 {
|
||||
fatal("small map with no empty slot (concurrent map writes?)")
|
||||
}
|
||||
|
|
|
|||
|
|
@ -160,9 +160,10 @@ func (m *Map) putSlotSmallFast32(typ *abi.SwissMapType, hash uintptr, key uint32
|
|||
match = match.removeFirst()
|
||||
}
|
||||
|
||||
// No need to look for deleted slots, small maps can't have them (see
|
||||
// deleteSmall).
|
||||
match = g.ctrls().matchEmpty()
|
||||
// There can't be deleted slots, small maps can't have them
|
||||
// (see deleteSmall). Use matchEmptyOrDeleted as it is a bit
|
||||
// more efficient than matchEmpty.
|
||||
match = g.ctrls().matchEmptyOrDeleted()
|
||||
if match == 0 {
|
||||
fatal("small map with no empty slot (concurrent map writes?)")
|
||||
}
|
||||
|
|
|
|||
|
|
@ -159,9 +159,10 @@ func (m *Map) putSlotSmallFast64(typ *abi.SwissMapType, hash uintptr, key uint64
|
|||
match = match.removeFirst()
|
||||
}
|
||||
|
||||
// No need to look for deleted slots, small maps can't have them (see
|
||||
// deleteSmall).
|
||||
match = g.ctrls().matchEmpty()
|
||||
// There can't be deleted slots, small maps can't have them
|
||||
// (see deleteSmall). Use matchEmptyOrDeleted as it is a bit
|
||||
// more efficient than matchEmpty.
|
||||
match = g.ctrls().matchEmptyOrDeleted()
|
||||
if match == 0 {
|
||||
fatal("small map with no empty slot (concurrent map writes?)")
|
||||
}
|
||||
|
|
@ -336,9 +337,10 @@ func (m *Map) putSlotSmallFastPtr(typ *abi.SwissMapType, hash uintptr, key unsaf
|
|||
match = match.removeFirst()
|
||||
}
|
||||
|
||||
// No need to look for deleted slots, small maps can't have them (see
|
||||
// deleteSmall).
|
||||
match = g.ctrls().matchEmpty()
|
||||
// There can't be deleted slots, small maps can't have them
|
||||
// (see deleteSmall). Use matchEmptyOrDeleted as it is a bit
|
||||
// more efficient than matchEmpty.
|
||||
match = g.ctrls().matchEmptyOrDeleted()
|
||||
if match == 0 {
|
||||
fatal("small map with no empty slot (concurrent map writes?)")
|
||||
}
|
||||
|
|
|
|||
|
|
@ -176,9 +176,10 @@ func (m *Map) putSlotSmallFastStr(typ *abi.SwissMapType, hash uintptr, key strin
|
|||
match = match.removeFirst()
|
||||
}
|
||||
|
||||
// No need to look for deleted slots, small maps can't have them (see
|
||||
// deleteSmall).
|
||||
match = g.ctrls().matchEmpty()
|
||||
// There can't be deleted slots, small maps can't have them
|
||||
// (see deleteSmall). Use matchEmptyOrDeleted as it is a bit
|
||||
// more efficient than matchEmpty.
|
||||
match = g.ctrls().matchEmptyOrDeleted()
|
||||
if match == 0 {
|
||||
fatal("small map with no empty slot (concurrent map writes?)")
|
||||
}
|
||||
|
|
|
|||
|
|
@ -381,6 +381,8 @@ func (t *table) PutSlot(typ *abi.SwissMapType, m *Map, hash uintptr, key unsafe.
|
|||
// Requires that the entry does not exist in the table, and that the table has
|
||||
// room for another element without rehashing.
|
||||
//
|
||||
// Requires that there are no deleted entries in the table.
|
||||
//
|
||||
// Never returns nil.
|
||||
func (t *table) uncheckedPutSlot(typ *abi.SwissMapType, hash uintptr, key unsafe.Pointer) unsafe.Pointer {
|
||||
if t.growthLeft == 0 {
|
||||
|
|
@ -395,7 +397,7 @@ func (t *table) uncheckedPutSlot(typ *abi.SwissMapType, hash uintptr, key unsafe
|
|||
for ; ; seq = seq.next() {
|
||||
g := t.groups.group(typ, seq.offset)
|
||||
|
||||
match := g.ctrls().matchEmpty()
|
||||
match := g.ctrls().matchEmptyOrDeleted()
|
||||
if match != 0 {
|
||||
i := match.first()
|
||||
|
||||
|
|
@ -414,9 +416,7 @@ func (t *table) uncheckedPutSlot(typ *abi.SwissMapType, hash uintptr, key unsafe
|
|||
slotElem = emem
|
||||
}
|
||||
|
||||
if g.ctrls().get(i) == ctrlEmpty {
|
||||
t.growthLeft--
|
||||
}
|
||||
t.growthLeft--
|
||||
g.ctrls().set(i, ctrl(h2(hash)))
|
||||
return slotElem
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in New Issue