Skip to content

Conversation

@browner12
Copy link
Contributor

in all of these changes, take() is a direct alias of the limit() method, and performs no additional logic. switching to directly calling the limit() method means less code execution (minimallly better performance) and reduces the call stack (nice for debugging).

a bit more subjective, but I would also argue that "limit" is a little clearer semantically about what it is doing to the query, whereas "take" has the implication that you're selecting everything and then taking a subset of that result.

in all of these changes, `take()` is a direct alias of the `limit()` method, and performs no additional logic. switching to directly calling the `limit()` method means less code execution (minimallly better performance) and reduces the call stack (nice for debugging). a bit more subjective, but I would also argue that "limit" is a little clearer semantically about what it is doing to the query, whereas "take" has the implication that you're selecting everything and then taking a subset of that result.
@taylorotwell taylorotwell merged commit 9f03dc6 into laravel:12.x Jun 19, 2025
59 of 60 checks passed
@browner12 browner12 deleted the AB-take-limit-optimization branch June 19, 2025 20:10
@AhmedAlaa4611
Copy link
Contributor

In a quick GitHub search, I think we have more take() that needs to be removed.

@browner12
Copy link
Contributor Author

are you sure they are specifically take() calls from the Builder class? could you provide an example?

@AhmedAlaa4611
Copy link
Contributor

Apologies, I double-checked, and these are not calls from the Builder class.

mohammad-fouladgar pushed a commit to mohammad-fouladgar/framework that referenced this pull request Jul 22, 2025
* use `limit()` in place of `take()` in all of these changes, `take()` is a direct alias of the `limit()` method, and performs no additional logic. switching to directly calling the `limit()` method means less code execution (minimallly better performance) and reduces the call stack (nice for debugging). a bit more subjective, but I would also argue that "limit" is a little clearer semantically about what it is doing to the query, whereas "take" has the implication that you're selecting everything and then taking a subset of that result. * fix test mock --------- Co-authored-by: Taylor Otwell <taylor@laravel.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

3 participants