aboutsummaryrefslogtreecommitdiff
path: root/src/internal/runtime/maps/export_test.go
diff options
context:
space:
mode:
Diffstat (limited to 'src/internal/runtime/maps/export_test.go')
-rw-r--r--src/internal/runtime/maps/export_test.go36
1 files changed, 36 insertions, 0 deletions
diff --git a/src/internal/runtime/maps/export_test.go b/src/internal/runtime/maps/export_test.go
index 369ef1f2fe..8f62739665 100644
--- a/src/internal/runtime/maps/export_test.go
+++ b/src/internal/runtime/maps/export_test.go
@@ -36,12 +36,48 @@ func (m *Map) GroupCount() uint64 {
return n
}
+// Return a key from a group containing no empty slots, or nil if there are no
+// full groups.
+//
+// Also returns nil if a group is full but contains entirely deleted slots.
+func (m *Map) KeyFromFullGroup() unsafe.Pointer {
+ var lastTab *table
+ for _, t := range m.directory {
+ if t == lastTab {
+ continue
+ }
+ lastTab = t
+
+ for i := uint64(0); i <= t.groups.lengthMask; i++ {
+ g := t.groups.group(i)
+ match := g.ctrls().matchEmpty()
+ if match != 0 {
+ continue
+ }
+
+ // All full or deleted slots.
+ for j := uint32(0); j < abi.SwissMapGroupSlots; j++ {
+ if g.ctrls().get(j) == ctrlDeleted {
+ continue
+ }
+ return g.key(j)
+ }
+ }
+ }
+
+ return nil
+}
+
func (m *Map) TableFor(key unsafe.Pointer) *table {
hash := m.typ.Hasher(key, m.seed)
idx := m.directoryIndex(hash)
return m.directory[idx]
}
+func (t *table) GrowthLeft() uint64 {
+ return uint64(t.growthLeft)
+}
+
// Returns the start address of the groups array.
func (t *table) GroupsStart() unsafe.Pointer {
return t.groups.data