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>
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?)")
}
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?)")
}
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?)")
}
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?)")
}
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?)")
}
// 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 {
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()
slotElem = emem
}
- if g.ctrls().get(i) == ctrlEmpty {
- t.growthLeft--
- }
+ t.growthLeft--
g.ctrls().set(i, ctrl(h2(hash)))
return slotElem
}