Browse Source

Inline strings.IndexRune call

This is worth about 4% on
github.com/julienschmidt/go-http-routing-benchmark's
BenchmarkGoji_GithubAll.
Carl Jackson 12 years ago
parent
commit
d0d00ae437
1 changed files with 5 additions and 3 deletions
  1. +5
    -3
      web/pattern.go

+ 5
- 3
web/pattern.go View File

@ -174,9 +174,11 @@ func (s stringPattern) match(r *http.Request, c *C, dryrun bool) bool {
} }
path = path[len(sli):] path = path[len(sli):]
m := strings.IndexRune(path, '/')
if m == -1 {
m = len(path)
m := 0
for ; m < len(path); m++ {
if path[m] == '/' {
break
}
} }
if m == 0 { if m == 0 {
// Empty strings are not matches, otherwise routes like // Empty strings are not matches, otherwise routes like


Loading…
Cancel
Save