dirIdx int
// tab is the table at dirIdx during the previous call to Next.
- tab *table
- groupSmall groupReference // only if small map at init
+ tab *table
+
+ // group is the group at entryIdx during the previous call to Next.
+ group groupReference
// entryIdx is the current entry index, prior to adjustment by entryOffset.
// The lower 3 bits of the index are the slot index, and the upper bits
it.dirOffset = rand()
it.globalDepth = m.globalDepth
it.dirIdx = dirIdx
- it.groupSmall = groupSmall
+ it.group = groupSmall
it.clearSeq = m.clearSeq
}
if it.dirIdx < 0 {
// Map was small at Init.
- g := it.groupSmall
for ; it.entryIdx < abi.SwissMapGroupSlots; it.entryIdx++ {
k := uintptr(it.entryIdx+it.entryOffset) % abi.SwissMapGroupSlots
- if (g.ctrls().get(k) & ctrlEmpty) == ctrlEmpty {
+ if (it.group.ctrls().get(k) & ctrlEmpty) == ctrlEmpty {
// Empty or deleted.
continue
}
- key := g.key(it.typ, k)
+ key := it.group.key(it.typ, k)
if it.typ.IndirectKey() {
key = *((*unsafe.Pointer)(key))
}
if !ok {
// See comment below.
if it.clearSeq == it.m.clearSeq && !it.typ.Key.Equal(key, key) {
- elem = g.elem(it.typ, k)
+ elem = it.group.elem(it.typ, k)
if it.typ.IndirectElem() {
elem = *((*unsafe.Pointer)(elem))
}
elem = newElem
}
} else {
- elem = g.elem(it.typ, k)
+ elem = it.group.elem(it.typ, k)
if it.typ.IndirectElem() {
elem = *((*unsafe.Pointer)(elem))
}
it.tab = newTab
}
- var g groupReference
-
// N.B. Use it.tab, not newTab. It is important to use the old
// table for key selection if the table has grown. See comment
// on grown below.
entryIdx := (it.entryIdx + it.entryOffset) & it.tab.groups.entryMask
slotIdx := uintptr(entryIdx & (abi.SwissMapGroupSlots - 1))
- if slotIdx == 0 || g.data == nil {
+ if slotIdx == 0 || it.group.data == nil {
// Only compute the group (a) when we switch
// groups (slotIdx rolls over) and (b) on the
// first iteration in this table (slotIdx may
// not be zero due to entryOffset).
groupIdx := entryIdx >> abi.SwissMapGroupSlotsBits
- g = it.tab.groups.group(it.typ, groupIdx)
+ it.group = it.tab.groups.group(it.typ, groupIdx)
}
// TODO(prattmic): Skip over groups that are composed of only empty
// or deleted slots using matchEmptyOrDeleted() and counting the
// number of bits set.
- if (g.ctrls().get(slotIdx) & ctrlEmpty) == ctrlEmpty {
+ if (it.group.ctrls().get(slotIdx) & ctrlEmpty) == ctrlEmpty {
// Empty or deleted.
continue
}
- key := g.key(it.typ, slotIdx)
+ key := it.group.key(it.typ, slotIdx)
if it.typ.IndirectKey() {
key = *((*unsafe.Pointer)(key))
}
// need to return anything added after
// clear.
if it.clearSeq == it.m.clearSeq && !it.typ.Key.Equal(key, key) {
- elem = g.elem(it.typ, slotIdx)
+ elem = it.group.elem(it.typ, slotIdx)
if it.typ.IndirectElem() {
elem = *((*unsafe.Pointer)(elem))
}
elem = newElem
}
} else {
- elem = g.elem(it.typ, slotIdx)
+ elem = it.group.elem(it.typ, slotIdx)
if it.typ.IndirectElem() {
elem = *((*unsafe.Pointer)(elem))
}
entries := 1 << (it.m.globalDepth - it.tab.localDepth)
it.dirIdx += entries
it.tab = nil
+ it.group = groupReference{}
it.entryIdx = 0
}