@@ -11,7 +11,6 @@ import (
1111 "reflect"
1212 "strconv"
1313 "strings"
14- "unsafe"
1514
1615 "github.com/dlclark/regexp2"
1716)
@@ -747,20 +746,15 @@ func regexpToRegexp(path *regexp2.Regexp, tokens *[]Token) *regexp2.Regexp {
747746 }
748747
749748 if totalGroupCount > 0 {
750- newTokens := append (make ([]Token , 0 ), * tokens ... )
751-
752749 for i := 0 ; i < totalGroupCount ; i ++ {
753- newTokens = append (newTokens , Token {
750+ * tokens = append (* tokens , Token {
754751 Name : i ,
755752 Prefix : "" ,
756753 Suffix : "" ,
757754 Modifier : "" ,
758755 Pattern : "" ,
759756 })
760757 }
761-
762- hdr := (* reflect .SliceHeader )(unsafe .Pointer (tokens ))
763- * hdr = * (* reflect .SliceHeader )(unsafe .Pointer (& newTokens ))
764758 }
765759 }
766760
@@ -827,12 +821,6 @@ func tokensToRegExp(rawTokens []interface{}, tokens *[]Token, options *Options)
827821 route = "^"
828822 }
829823
830- var newTokens []Token
831- if tokens != nil {
832- newTokens = make ([]Token , 0 , len (* tokens )+ len (rawTokens ))
833- newTokens = append (newTokens , * tokens ... )
834- }
835-
836824 // Iterate over the tokens and create our regexp string.
837825 for _ , token := range rawTokens {
838826 if str , ok := token .(string ); ok {
@@ -855,7 +843,7 @@ func tokensToRegExp(rawTokens []interface{}, tokens *[]Token, options *Options)
855843
856844 if token .Pattern != "" {
857845 if tokens != nil {
858- newTokens = append (newTokens , token )
846+ * tokens = append (* tokens , token )
859847 }
860848 if prefix != "" || suffix != "" {
861849 if token .Modifier == "+" || token .Modifier == "*" {
@@ -879,11 +867,6 @@ func tokensToRegExp(rawTokens []interface{}, tokens *[]Token, options *Options)
879867 }
880868 }
881869
882- if tokens != nil {
883- hdr := (* reflect .SliceHeader )(unsafe .Pointer (tokens ))
884- * hdr = * (* reflect .SliceHeader )(unsafe .Pointer (& newTokens ))
885- }
886-
887870 if end {
888871 if ! strict {
889872 route += delimiter + "?"
0 commit comments