Closed
Description
I suggest using a possessive quantifier to improve the route matching performance (Symfony generates possessive quantifiers for its builtin requirements, but custom ones need to do that themselves, as using non-possessive quantifiers can still be a valid use case)
He's technically right, but we need to decide if we do that in this Demo app or not:
// BEFORE
@Route("/{id<\d+>}/edit",methods={"GET", "POST"}, name="admin_post_edit")
@Route("/page/{page<[1-9]\d*>}", defaults={"_format"="html"}, methods={"GET"}, name="blog_index_paginated")
// AFTER
@Route("/{id<\d++>}/edit",methods={"GET", "POST"}, name="admin_post_edit")
@Route("/page/{page<[1-9]\d*+>}", defaults={"_format"="html"}, methods={"GET"}, name="blog_index_paginated")
Some pros and cons:
- (Con) This is a Demo app not a benchmark app, so clarity is preferred over speed.
- (Con) The
\d++
and\d*+
can confuse lots of developers who don't know regexp well - (Pro) Using these can be a good opportunity to help teach about them.
- (Pro) It makes the routing slightly faster
- ...
Metadata
Metadata
Assignees
Labels
No labels