Skip to content

Commit

Permalink
feat: use const for star delim
Browse files Browse the repository at this point in the history
  • Loading branch information
tigerwill90 committed Oct 24, 2024
1 parent 33d5154 commit 17c29a6
Showing 1 changed file with 4 additions and 3 deletions.
7 changes: 4 additions & 3 deletions tree.go
Original file line number Diff line number Diff line change
Expand Up @@ -528,6 +528,7 @@ func (t *Tree) remove(method, path string) bool {
const (
slashDelim = '/'
bracketDelim = '{'
starDelim = '*'
)

func (t *Tree) lookup(target *node, path string, c *cTx, lazy bool) (n *node, tsr bool) {
Expand All @@ -550,8 +551,8 @@ Walk:
break
}

if current.key[i] != path[charsMatched] || path[charsMatched] == bracketDelim || path[charsMatched] == '*' {
if current.key[i] == '{' {
if current.key[i] != path[charsMatched] || path[charsMatched] == bracketDelim || path[charsMatched] == starDelim {
if current.key[i] == bracketDelim {
startPath := charsMatched
idx := strings.IndexByte(path[charsMatched:], slashDelim)
if idx > 0 {
Expand Down Expand Up @@ -584,7 +585,7 @@ Walk:
continue
}

if current.key[i] == '*' {
if current.key[i] == starDelim {
// | current.params[paramKeyCnt].end (10)
// key: foo/*{bar}/ => 10 - 5 = 5 => i+=idx set i to '/'
// | charsMatchedInNodeFound (5)
Expand Down

0 comments on commit 17c29a6

Please sign in to comment.