Merge pull request #7 from splashsky/improve-tokenizing-speed

⏱️ Replace preg_replace in tokenize with str_replace
This commit is contained in:
Skylear 2021-07-15 17:28:38 -05:00 committed by GitHub
commit c45aed8ec8
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -131,12 +131,12 @@ class Router
$matches = $matches[1];
foreach ($matches as $match) {
$pattern = "/(?:{".$match."})+/";
$pattern = '{'.$match.'}';
if (in_array($match, $constraints)) {
$uri = preg_replace($pattern, '('.self::$constraints[$match].')', $uri);
$uri = str_replace($pattern, '('.self::$constraints[$match].')', $uri);
} else {
$uri = preg_replace($pattern, self::$defaultConstraint, $uri);
$uri = str_replace($pattern, self::$defaultConstraint, $uri);
}
}