mirror of
https://github.com/golang/go
synced 2024-11-23 18:30:06 -07:00
cmd/go/internal/mvs: Delete redundant searching for maximum version when building minimal requirement list
mvs.Req performs an unnecessary search for the maximum version when building minimal requirement list. Someone may be confused when reading this piece of code. The comment of the BuildList function also states that the build list contains the maximum version of each module. We just need to create a maximum version cache that maps from path to version, in the beginning of the Req function body.
Change-Id: I4b353e167f2dcc96bc13cc2e1c602bce47c72bc9
GitHub-Last-Rev: fce11d3c72
GitHub-Pull-Request: golang/go#50345
Reviewed-on: https://go-review.googlesource.com/c/go/+/374277
Auto-Submit: Bryan Mills <bcmills@google.com>
Run-TryBot: Bryan Mills <bcmills@google.com>
Reviewed-by: Bryan Mills <bcmills@google.com>
TryBot-Result: Gopher Robot <gobot@golang.org>
Reviewed-by: Heschi Kreinick <heschi@google.com>
This commit is contained in:
parent
cfccb5cb7c
commit
e755a5649a
@ -194,6 +194,11 @@ func Req(mainModule module.Version, base []string, reqs Reqs) ([]module.Version,
|
||||
// that list came from a previous operation that paged
|
||||
// in all the requirements, so there's no I/O to overlap now.
|
||||
|
||||
max := map[string]string{}
|
||||
for _, m := range list {
|
||||
max[m.Path] = m.Version
|
||||
}
|
||||
|
||||
// Compute postorder, cache requirements.
|
||||
var postorder []module.Version
|
||||
reqCache := map[module.Version][]module.Version{}
|
||||
@ -236,14 +241,6 @@ func Req(mainModule module.Version, base []string, reqs Reqs) ([]module.Version,
|
||||
}
|
||||
return nil
|
||||
}
|
||||
max := map[string]string{}
|
||||
for _, m := range list {
|
||||
if v, ok := max[m.Path]; ok {
|
||||
max[m.Path] = reqs.Max(m.Version, v)
|
||||
} else {
|
||||
max[m.Path] = m.Version
|
||||
}
|
||||
}
|
||||
// First walk the base modules that must be listed.
|
||||
var min []module.Version
|
||||
haveBase := map[string]bool{}
|
||||
|
Loading…
Reference in New Issue
Block a user