Commit eec9a895 authored by Russ Cox's avatar Russ Cox

cmd/go/internal/str: simplify HasPathPrefix by epsilon

Pointed out in CL 122396.
An empty prefix has already been handled above.

Change-Id: Ib94df0a9c8c0517f932b90126232111caa9ad289
Reviewed-on: https://go-review.googlesource.com/124797Reviewed-by: 's avatarBryan C. Mills <bcmills@google.com>
parent 6140829e
......@@ -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
}
}
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment