From 93b49f773d1a4b706f5352dffb912c259c15dc4f Mon Sep 17 00:00:00 2001 From: Nick Ripley Date: Thu, 4 Dec 2025 10:01:21 -0500 Subject: [PATCH] internal/runtime/maps: clarify probeSeq doc comment The probeSeq doc comment describes the probe sequence as triangular and gives the formula for terms in the sequence. This formula isn't actually used in the code, though. List the first few terms of the sequence explicitly so the connection between the description and the code is more clear. Change-Id: I6a6a69648bc94e15df436815c16128ebef3c6eb8 Reviewed-on: https://go-review.googlesource.com/c/go/+/726820 LUCI-TryBot-Result: Go LUCI Reviewed-by: Michael Pratt Reviewed-by: Dmitri Shuralyov --- src/internal/runtime/maps/table.go | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/src/internal/runtime/maps/table.go b/src/internal/runtime/maps/table.go index 8a1932e453..977f3091ad 100644 --- a/src/internal/runtime/maps/table.go +++ b/src/internal/runtime/maps/table.go @@ -1260,8 +1260,10 @@ func (t *table) grow(typ *abi.MapType, m *Map, newCapacity uint16) { // probeSeq maintains the state for a probe sequence that iterates through the // groups in a table. The sequence is a triangular progression of the form +// hash, hash + 1, hash + 1 + 2, hash + 1 + 2 + 3, ..., modulo mask + 1. +// The i-th term of the sequence is // -// p(i) := (i^2 + i)/2 + hash (mod mask+1) +// p(i) := hash + (i^2 + i)/2 (mod mask+1) // // The sequence effectively outputs the indexes of *groups*. The group // machinery allows us to check an entire group with minimal branching. -- 2.52.0