internal/anyunique: new package
In order to avoid O(N^2) behaviour in encoding/jsonschema.Generate,
we want some way to efficiently compare generated JSON Schema
fragments for structural equality.
This new package makes that easier to accomplish by storing items
uniquely by structural equality. The Hash interface used is the same
as that proposed for the standard library [1].
Note that having a separate type for the canonical unique values
is very helpful so the compiler can help to tell the caller
when it's OK to compare using `==`.
[1]: https://go-review.googlesource.com/c/go/+/657296/11/src/hash/maphash/hasher.go
Signed-off-by: Roger Peppe <rogpeppe@gmail.com>
Change-Id: Iddab07c0c2207040700e66fafd00a7c4f503cbae
Reviewed-on: https://review.gerrithub.io/c/cue-lang/cue/+/1224573
Reviewed-by: Daniel Martí <mvdan@mvdan.cc>
Unity-Result: CUE porcuepine <cue.porcuepine@gmail.com>
TryBot-Result: CUEcueckoo <cueckoo@cuelang.org>