Skip to content

Commit

Permalink
cmd/go/internal/str: simplify HasPathPrefix by epsilon
Browse files Browse the repository at this point in the history
Pointed out in CL 122396.
An empty prefix has already been handled above.

Change-Id: Ib94df0a9c8c0517f932b90126232111caa9ad289
Reviewed-on: https://go-review.googlesource.com/124797
Reviewed-by: Bryan C. Mills <[email protected]>
  • Loading branch information
rsc committed Jul 19, 2018
1 parent 6140829 commit eec9a89
Showing 1 changed file with 1 addition and 1 deletion.
2 changes: 1 addition & 1 deletion src/cmd/go/internal/str/path.go
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ func HasPathPrefix(s, prefix string) bool {
return true
}
if len(s) > len(prefix) {
if prefix != "" && prefix[len(prefix)-1] == '/' || s[len(prefix)] == '/' {
if prefix[len(prefix)-1] == '/' || s[len(prefix)] == '/' {
return s[:len(prefix)] == prefix
}
}
Expand Down

0 comments on commit eec9a89

Please sign in to comment.