Browse Source

Move patternRe closer to its use

Carl Jackson 12 years ago
parent
commit
70edd84d7c
2 changed files with 2 additions and 2 deletions
  1. +2
    -0
      web/pattern.go
  2. +0
    -2
      web/router.go

+ 2
- 0
web/pattern.go View File

@ -194,6 +194,8 @@ func (s stringPattern) String() string {
return fmt.Sprintf("stringPattern(%q, %v)", s.raw, s.isPrefix) return fmt.Sprintf("stringPattern(%q, %v)", s.raw, s.isPrefix)
} }
var patternRe = regexp.MustCompile(`/:([^/]+)`)
func parseStringPattern(s string, isPrefix bool) stringPattern { func parseStringPattern(s string, isPrefix bool) stringPattern {
matches := patternRe.FindAllStringSubmatchIndex(s, -1) matches := patternRe.FindAllStringSubmatchIndex(s, -1)
pats := make([]string, len(matches)) pats := make([]string, len(matches))


+ 0
- 2
web/router.go View File

@ -65,8 +65,6 @@ type Pattern interface {
Match(r *http.Request, c *C) bool Match(r *http.Request, c *C) bool
} }
var patternRe = regexp.MustCompile(`/:([^/]+)`)
func parsePattern(p interface{}, isPrefix bool) Pattern { func parsePattern(p interface{}, isPrefix bool) Pattern {
switch p.(type) { switch p.(type) {
case Pattern: case Pattern:


Loading…
Cancel
Save