Skip to content

Conversation

AhmedAlaa4611
Copy link
Contributor

Description

This PR refactors the recorded() method in the HTTP client to avoid an unnecessary call to filter() when no callback is provided.

Currently, when $callback is null, the method creates a default closure that always returns true, then filters the entire collection; effectively doing nothing but still iterating over the data.

This change short-circuits that path by simply returning the collection directly when no filtering is needed, resulting in slightly better performance and improved clarity, especially when dealing with large numbers of recorded request/response pairs.

@taylorotwell taylorotwell merged commit d6ecb78 into laravel:12.x Jul 7, 2025
62 checks passed
mohammad-fouladgar pushed a commit to mohammad-fouladgar/framework that referenced this pull request Jul 22, 2025
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