Commit 6631f227 authored by Kunpei Sakai's avatar Kunpei Sakai Committed by Brad Fitzpatrick

net/http: avoid for-loop if possible

Change-Id: I01900c3a2ebdda8c90d0585f179a39ee890c417f
Reviewed-on: https://go-review.googlesource.com/87336Reviewed-by: 's avatarBrad Fitzpatrick <bradfitz@golang.org>
Run-TryBot: Brad Fitzpatrick <bradfitz@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org>
parent 08e342d6
......@@ -2242,9 +2242,12 @@ func (mux *ServeMux) shouldRedirect(host, path string) bool {
}
n := len(path)
if n == 0 {
return false
}
for _, c := range p {
if _, exist := mux.m[c+"/"]; exist {
return n > 0 && path[n-1] != '/'
return path[n-1] != '/'
}
}
......
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