]> Cypherpunks repositories - gostls13.git/commit
cmd/go/internal/fsys: replace file tree with sorted list
authorRuss Cox <rsc@golang.org>
Tue, 19 Nov 2024 13:34:07 +0000 (08:34 -0500)
committerRuss Cox <rsc@golang.org>
Tue, 19 Nov 2024 16:43:49 +0000 (16:43 +0000)
commit44cea1234dc18352fec89285e94f92693034323d
tree5438b7bbd4333ef54b8f184896f37fe5bc3a54da
parent2ef00e2734aa724ff44bc5d706657b60731cf835
cmd/go/internal/fsys: replace file tree with sorted list

Replace the tree of nodes with a sorted list of file replacements.
The most important property of this representation is that it
allows replacing directories: a replacement x -> y where y is
a directory could not be implemented before, because it would
require making a node for every file in the tree rooted at y,
or else it would require unsuccessful lookups for files like
x/a/b/c/d/e/f/g/h/i/j/k to try every possible parent in order
to discover the x -> y mapping.

The sorted list makes it easy to find the x -> y mapping:
when you do the binary search for x/a/b/c/d/e/f/g/h/i/j/k,
you end up immediately after the x -> y mapping, so stepping
backward one entry provides the mapping we need, if it exists.

This CL does not allow overlay files to include directories,
but now it is possible. This is at least useful for other kinds
of experiments (like FIPS).

Change-Id: Ief0afaee82e644dab8ae4eafeec20440afee2e36
Reviewed-on: https://go-review.googlesource.com/c/go/+/628701
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
Reviewed-by: Michael Matloob <matloob@golang.org>
src/cmd/go/internal/fsys/fsys.go
src/cmd/go/internal/fsys/fsys_test.go