1
0
mirror of https://github.com/golang/go synced 2024-11-15 12:20:32 -07:00
go/doc/next/6-stdlib/2-unique.md
guoguangwu 4792ca7b93 doc: fix typos in docs
Change-Id: Ib51283b35d6d35acd7a90cd531ff6897a23d9894
GitHub-Last-Rev: dd485f332e
GitHub-Pull-Request: golang/go#66985
Reviewed-on: https://go-review.googlesource.com/c/go/+/580797
Reviewed-by: Ian Lance Taylor <iant@google.com>
Auto-Submit: Ian Lance Taylor <iant@google.com>
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
Reviewed-by: Joedian Reid <joedian@google.com>
2024-04-24 13:37:36 +00:00

579 B

New unique package

The new unique package provides facilities for canonicalizing values (like "interning" or "hash-consing").

Any value of comparable type may be canonicalized with the new Make[T] function, which produces a reference to a canonical copy of the value in the form of a Handle[T]. Two Handle[T] are equal if and only if the values used to produce the handles are equal, allowing programs to deduplicate values and reduce their memory footprint. Comparing two Handle[T] values is efficient, reducing down to a simple pointer comparison.