Skip to content

[12.x] Do not loop through middleware when excluded is empty#54837

Merged
taylorotwell merged 3 commits into
laravel:12.xfrom
cosmastech:simplify-middleware
Feb 28, 2025
Merged

[12.x] Do not loop through middleware when excluded is empty#54837
taylorotwell merged 3 commits into
laravel:12.xfrom
cosmastech:simplify-middleware

Conversation

@cosmastech

@cosmastech cosmastech commented Feb 27, 2025

Copy link
Copy Markdown
Contributor

Just a minor optimization here. Each time the closure is called, it's checking if excluded is empty. We can just check that before starting the loop. Also, this avoids running filter functions on an empty excluded middleware array.

I recognize these are both relatively minor optimizations and probably wouldn't be noticeable for most applications.

@github-actions

Copy link
Copy Markdown

Thanks for submitting a PR!

Note that draft PR's are not reviewed. If you would like a review, please mark your pull request as ready for review in the GitHub user interface.

Pull requests that are abandoned in draft may be closed due to inactivity.

@cosmastech cosmastech marked this pull request as ready for review February 27, 2025 23:35
@taylorotwell taylorotwell merged commit 7b8e12d into laravel:12.x Feb 28, 2025
@cosmastech cosmastech deleted the simplify-middleware branch January 24, 2026 13:06
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