Skip to content

Commit c45aed8

Browse files
author
Skylear
authored
Merge pull request #7 from splashsky/improve-tokenizing-speed
⏱️ Replace preg_replace in tokenize with str_replace
2 parents 2366121 + 559196b commit c45aed8

File tree

1 file changed

+3
-3
lines changed

1 file changed

+3
-3
lines changed

src/Splashsky/Router.php

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -131,12 +131,12 @@ private static function tokenize(string $uri)
131131
$matches = $matches[1];
132132

133133
foreach ($matches as $match) {
134-
$pattern = "/(?:{".$match."})+/";
134+
$pattern = '{'.$match.'}';
135135

136136
if (in_array($match, $constraints)) {
137-
$uri = preg_replace($pattern, '('.self::$constraints[$match].')', $uri);
137+
$uri = str_replace($pattern, '('.self::$constraints[$match].')', $uri);
138138
} else {
139-
$uri = preg_replace($pattern, self::$defaultConstraint, $uri);
139+
$uri = str_replace($pattern, self::$defaultConstraint, $uri);
140140
}
141141
}
142142

0 commit comments

Comments
 (0)