go/src/unique
Jake Bailey 27ff0f249c cmd/compile/internal/ssa: eliminate string copies for calls to unique.Make
unique.Make always copies strings passed into it, so it's safe to not
copy byte slices converted to strings either. Handle this just like map
accesses with string(b) as keys.

This CL only handles unique.Make(string(b)), not nested cases like
unique.Make([2]string{string(b1), string(b2)}); this could be done in a
followup CL but the map lookup code in walk is sufficiently different
than the call handling code that I didn't attempt it. (SSA is much
easier).

Fixes #71926

Change-Id: Ic2f82f2f91963d563b4ddb1282bd49fc40da8b85
Reviewed-on: https://go-review.googlesource.com/c/go/+/672135
Reviewed-by: David Chase <drchase@google.com>
Reviewed-by: Cherry Mui <cherryyz@google.com>
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
2025-05-21 20:20:31 -07:00
..
canonmap.go unique: use a bespoke canonicalization map and runtime.AddCleanup 2025-05-06 13:25:43 -07:00
canonmap_test.go unique: use a bespoke canonicalization map and runtime.AddCleanup 2025-05-06 13:25:43 -07:00
clone.go cmd/compile, unique: model data flow of non-string pointers 2025-05-21 20:07:36 -07:00
clone_test.go unique: use TypeFor instead of TypeOf to get type in Make 2024-08-21 16:03:35 +00:00
doc.go unique: add unique package and implement Make/Handle 2024-04-22 18:14:07 +00:00
handle.go runtime: schedule cleanups across multiple goroutines 2025-05-08 11:10:33 -07:00
handle_bench_test.go unique: add unique package and implement Make/Handle 2024-04-22 18:14:07 +00:00
handle_test.go cmd/compile/internal/ssa: eliminate string copies for calls to unique.Make 2025-05-21 20:20:31 -07:00