]> Cypherpunks repositories - gostls13.git/commitdiff
internal/runtime/maps: clarify probeSeq doc comment
authorNick Ripley <nick.ripley@datadoghq.com>
Thu, 4 Dec 2025 15:01:21 +0000 (10:01 -0500)
committerNick Ripley <nick.ripley@datadoghq.com>
Fri, 5 Dec 2025 15:01:07 +0000 (07:01 -0800)
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 <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
Reviewed-by: Michael Pratt <mpratt@google.com>
Reviewed-by: Dmitri Shuralyov <dmitshur@google.com>
src/internal/runtime/maps/table.go

index 8a1932e453f3c55ffdff130226fe338450cc939c..977f3091ade20383446ca3735369734217b43a2e 100644 (file)
@@ -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.