Skip to content
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

[8.x] Don't iterate over all collection in Collection::firstOrFail #38536

Merged
merged 1 commit into from
Aug 25, 2021
Merged

[8.x] Don't iterate over all collection in Collection::firstOrFail #38536

merged 1 commit into from
Aug 25, 2021

Conversation

bastien-phi
Copy link
Contributor

Illuminate\Support\Collection::firstOrFail actually iterates over every items of the collection, even if this is not needed.

This PR changes the implementation to stop iterating on first match, if exists.

@taylorotwell taylorotwell merged commit d110386 into laravel:8.x Aug 25, 2021
@bastien-phi
Copy link
Contributor Author

Thanks !

@bastien-phi bastien-phi deleted the change_collection_first_or_fail branch August 25, 2021 13:55
victorvilella pushed a commit to cdsistemas/framework that referenced this pull request Oct 12, 2021
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