]> Cypherpunks repositories - gostls13.git/commit
internal/runtime/maps: proper capacity hint handling
authorMichael Pratt <mpratt@google.com>
Thu, 12 Sep 2024 14:44:38 +0000 (10:44 -0400)
committerGopher Robot <gobot@golang.org>
Wed, 30 Oct 2024 14:07:22 +0000 (14:07 +0000)
commit3b424cfa9d2704a283bdba544497daad0d47fb65
treef76053ce29f77f5f0e62ba2c73be4e197c5e9388
parent89d7f031720c999e8226cd9624cc2c531f8477e3
internal/runtime/maps: proper capacity hint handling

When given a hint size, set the initial capacity large enough to avoid
requiring growth in the average case.

When not given a hint (or given 0), don't allocate anything at all.

For #54766.

Cq-Include-Trybots: luci.golang.try:gotip-linux-amd64-longtest-swissmap
Change-Id: I8844fc652b8d2d4e5136cd56f7e78999a07fe381
Reviewed-on: https://go-review.googlesource.com/c/go/+/616457
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
Reviewed-by: Keith Randall <khr@golang.org>
Reviewed-by: Keith Randall <khr@google.com>
Auto-Submit: Michael Pratt <mpratt@google.com>
12 files changed:
src/go/build/deps_test.go
src/internal/runtime/maps/export_test.go
src/internal/runtime/maps/map.go
src/internal/runtime/maps/map_swiss_test.go
src/internal/runtime/maps/runtime.go
src/internal/runtime/maps/runtime_noswiss.go [new file with mode: 0644]
src/internal/runtime/maps/runtime_swiss.go
src/internal/runtime/maps/table.go
src/runtime/alg.go
src/runtime/crash_test.go
src/runtime/map_swiss.go
src/runtime/panic.go