-
-
Notifications
You must be signed in to change notification settings - Fork 9.6k
[Routing] optimize static requirement on compile #6838
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Comments
Oh damnit, it is equivalent for matching but unfortunately not for generating a URL as a If it's not possible to do on compile securely, it can be done at least at dumping the matcher. |
@Tobion If I were to pickup on this would you guide me thru it? I know you said you know how to do it but I'd rather implement it so I can better understand the new routing component better. |
@Tobion this optimization could be done exclusively by the |
Actually, I think this optimization can be done by the RouteCompiler: the generator does not use the compiled regex pattern. Keeping the parameter in the compiled route variables will keep it away from the query string thanks to https://github.com/symfony/symfony/blob/master/src/Symfony/Component/Routing/Generator/UrlGenerator.php#L264 |
hmm, actually, I see 1 issue with this: the param would still be required because of the comparison with route variable but would be omitted because it matches the default added in the route, thus generating a different url. |
@jfsimon there is already an old PR for it, but the issue is BC. |
Looks like a lot of additional code for a very slight benefit. Closing. |
I sometimes see route definitions like the following where a requirement for a variable is no real regex but static text:
This is equivalent to
It can be optimized at compile time and would safe subpattern or even a complete regex match as in this case because the path is static now.
I already know how to implement this. This is just a reminder for me. ^^
Use
if (preg_quote($requirement) === $requirement)
for detection.The text was updated successfully, but these errors were encountered: