From 3ff510756b15d83c30946e0cab14b8104e167a1e Mon Sep 17 00:00:00 2001 From: tigerwill90 Date: Mon, 15 Jul 2024 18:17:39 +0200 Subject: [PATCH] feat: improve lookup speed for wildcard route --- node.go | 48 +++++++++++++++++++++--------------------------- 1 file changed, 21 insertions(+), 27 deletions(-) diff --git a/node.go b/node.go index 211ee1f..e02485a 100644 --- a/node.go +++ b/node.go @@ -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 { @@ -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