Skip to content

Commit

Permalink
feat: improve lookup speed for wildcard route
Browse files Browse the repository at this point in the history
  • Loading branch information
tigerwill90 committed Jul 15, 2024
1 parent 8ec458d commit 3ff5107
Showing 1 changed file with 21 additions and 27 deletions.
48 changes: 21 additions & 27 deletions node.go
Original file line number Diff line number Diff line change
Expand Up @@ -278,8 +278,6 @@ func parseWildcard(segment string) []param {
for i < len(segment) {
switch state {
case stateParam:
seg := string(segment[i])
_ = seg
if segment[i] == '}' {
end := -1
if len(segment[i+1:]) > 0 {
Expand All @@ -293,32 +291,28 @@ func parseWildcard(segment string) []param {
state = stateDefault
}
i++
case stateCatchAll:
seg := string(segment[i])
_ = seg
if segment[i] == '}' {
end := -1
if len(segment[i+1:]) > 0 {
end = i + 1
}
params = append(params, param{
key: segment[start:i],
end: end,
catchAll: true,
})
start = 0
state = stateDefault
}
i++
//case stateCatchAll:
//if segment[i] == '}' {
// end := -1
// if len(segment[i+1:]) > 0 {
// end = i + 1
// }
// params = append(params, param{
// key: segment[start:i],
// end: end,
// catchAll: true,
// })
// start = 0
// state = stateDefault
//}
//i++
default:
seg := string(segment[i])
_ = seg
if segment[i] == '*' {
state = stateCatchAll
i += 2
start = i
continue
}
// if segment[i] == '*' {
// state = stateCatchAll
// i += 2
// start = i
// continue
//}

if segment[i] == '{' {
state = stateParam
Expand Down

0 comments on commit 3ff5107

Please sign in to comment.