Skip to content

[12.x] optimize AbstractRouteCollection@matchAgainstRoute()#57871

Merged
taylorotwell merged 2 commits into
laravel:12.xfrom
cosmastech:optimize-matchAgainstRoutes
Nov 23, 2025
Merged

[12.x] optimize AbstractRouteCollection@matchAgainstRoute()#57871
taylorotwell merged 2 commits into
laravel:12.xfrom
cosmastech:optimize-matchAgainstRoutes

Conversation

@cosmastech

Copy link
Copy Markdown
Contributor

Keep a pointer to the first matching fallback route, but only loop through the routes once.

@taylorotwell taylorotwell merged commit 5583b8e into laravel:12.x Nov 23, 2025
74 checks passed
@cosmastech cosmastech deleted the optimize-matchAgainstRoutes branch November 23, 2025 13:51
akyrey pushed a commit to akyrey/framework that referenced this pull request Dec 29, 2025
…l#57871)

* optimize matchAgainstRoute

* Add fallback route handling in route matching

---------

Co-authored-by: Taylor Otwell <taylor@laravel.com>
SanderMuller added a commit to SanderMuller/framework that referenced this pull request Mar 15, 2026
…tion()

getByAction() wraps the entire attributes array in a Collection just
to call first() with a filter closure. This allocates a Collection
object unnecessarily when a plain foreach with early return achieves
the same result.

This follows the same pattern applied to matchAgainstRoutes() in
PR laravel#57871, which replaced Collection::first() with foreach for the
same reason.
SanderMuller added a commit to SanderMuller/framework that referenced this pull request Mar 19, 2026
…tion()

getByAction() wraps the entire attributes array in a Collection just
to call first() with a filter closure. This allocates a Collection
object unnecessarily when a plain foreach with early return achieves
the same result.

This follows the same pattern applied to matchAgainstRoutes() in
PR laravel#57871, which replaced Collection::first() with foreach for the
same reason.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants