]> Cypherpunks.ru repositories - gostls13.git/commit
cmd/go/internal/par: use generic Cache
authorRoger Peppe <rogpeppe@gmail.com>
Mon, 30 Jan 2023 17:27:42 +0000 (17:27 +0000)
committerroger peppe <rogpeppe@gmail.com>
Fri, 3 Feb 2023 09:56:24 +0000 (09:56 +0000)
commit2f2c5e41e7728cae99abd14e8bd5ffcfebf9df8e
tree4efc28e3178daff73df7bfed4c70056c6b2d3c66
parent9222a01e651f5968a1c66013f7094c265f4011e7
cmd/go/internal/par: use generic Cache

Using generics here makes the code easier to understand,
as the contract is clearly specified. It also makes the
code a little more concise, as it's easy to write a wrapper
for the cache that adds an error value, meaning that
a bunch of auxilliary types no longer need to be defined
for this common case.

The load.cachingRepo code has been changed to use a separate
cache for each key-value type combination, which seems a bit less
sleazy, but might have some knock-on effect on memory usage,
and could easily be changed back if desired.

Because there's no longer an unambiguous way to find out
whether there's an entry in the cache, the Cache.Get method
now returns a bool as well as the value itself.

Change-Id: I28443125bab0b3720cc95d750e72d28e9b96257d
Reviewed-on: https://go-review.googlesource.com/c/go/+/463843
Reviewed-by: Bryan Mills <bcmills@google.com>
Run-TryBot: roger peppe <rogpeppe@gmail.com>
TryBot-Result: Gopher Robot <gobot@golang.org>
Reviewed-by: Michael Knyszek <mknyszek@google.com>
17 files changed:
src/cmd/go/internal/load/pkg.go
src/cmd/go/internal/modfetch/cache.go
src/cmd/go/internal/modfetch/codehost/git.go
src/cmd/go/internal/modfetch/codehost/vcs.go
src/cmd/go/internal/modfetch/fetch.go
src/cmd/go/internal/modfetch/repo.go
src/cmd/go/internal/modget/get.go
src/cmd/go/internal/modindex/read.go
src/cmd/go/internal/modindex/scan.go
src/cmd/go/internal/modload/build.go
src/cmd/go/internal/modload/buildlist.go
src/cmd/go/internal/modload/import.go
src/cmd/go/internal/modload/load.go
src/cmd/go/internal/modload/modfile.go
src/cmd/go/internal/par/work.go
src/cmd/go/internal/par/work_test.go
src/cmd/go/proxy_test.go