Skip to content

Commit ba0dd3b

Browse files
callthingsoffgopherbot
authored andcommitted
cmd/go/internal/modload: avoid calling strings.HasPrefix twice in *MainModuleSet.DirImportPath
Since TrimPrefix uses HasPrefix internally. Change-Id: Ifadb99dd9192578056636adacaccc9d88a1c1f32 GitHub-Last-Rev: 74bcfff GitHub-Pull-Request: #63893 Reviewed-on: https://go-review.googlesource.com/c/go/+/539096 Run-TryBot: Jes Cok <[email protected]> Auto-Submit: Bryan Mills <[email protected]> Reviewed-by: Heschi Kreinick <[email protected]> TryBot-Result: Gopher Robot <[email protected]> Reviewed-by: Bryan Mills <[email protected]>
1 parent 374a56c commit ba0dd3b

File tree

1 file changed

+1
-1
lines changed

1 file changed

+1
-1
lines changed

src/cmd/go/internal/modload/load.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -777,7 +777,7 @@ func (mms *MainModuleSet) DirImportPath(ctx context.Context, dir string) (path s
777777
longestPrefixVersion = v
778778
suffix := filepath.ToSlash(str.TrimFilePathPrefix(dir, modRoot))
779779
if strings.HasPrefix(suffix, "vendor/") {
780-
longestPrefixPath = strings.TrimPrefix(suffix, "vendor/")
780+
longestPrefixPath = suffix[len("vendor/"):]
781781
continue
782782
}
783783
longestPrefixPath = pathpkg.Join(mms.PathPrefix(v), suffix)

0 commit comments

Comments
 (0)