mirror of
https://github.com/golang/go
synced 2024-11-26 16:07:00 -07:00
cmd/go/internal/modload: don't use strings.TrimPrefix in *MainModuleSet.DirImportPath
To avoid calling strings.HasPrefix twice, don't use strings.TrimPrefix.
This commit is contained in:
parent
6a7ef36466
commit
74bcfff3fb
@ -777,7 +777,7 @@ func (mms *MainModuleSet) DirImportPath(ctx context.Context, dir string) (path s
|
|||||||
longestPrefixVersion = v
|
longestPrefixVersion = v
|
||||||
suffix := filepath.ToSlash(str.TrimFilePathPrefix(dir, modRoot))
|
suffix := filepath.ToSlash(str.TrimFilePathPrefix(dir, modRoot))
|
||||||
if strings.HasPrefix(suffix, "vendor/") {
|
if strings.HasPrefix(suffix, "vendor/") {
|
||||||
longestPrefixPath = strings.TrimPrefix(suffix, "vendor/")
|
longestPrefixPath = suffix[len("vendor/"):]
|
||||||
continue
|
continue
|
||||||
}
|
}
|
||||||
longestPrefixPath = pathpkg.Join(mms.PathPrefix(v), suffix)
|
longestPrefixPath = pathpkg.Join(mms.PathPrefix(v), suffix)
|
||||||
|
Loading…
Reference in New Issue
Block a user