Skip to content

[12.x] Optimise join and set functions in Arr class #56043

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

Conversation

JordanchoEftimov
Copy link
Contributor

Improve Arr::set and Arr::join for clarity and performance

  • Optimized Arr::set to handle single-key cases early, reducing unnecessary loop execution and improving readability.
  • Optimized Arr::join by storing the count of the array once instead of calling count() multiple times, improving performance slightly and making the logic cleaner.


return $array;
}

foreach ($keys as $i => $key) {
if (count($keys) === 1) {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

you can remove this now?

@taylorotwell
Copy link
Member

Thanks for your pull request to Laravel!

Unfortunately, I'm going to delay merging this code for now. To preserve our ability to adequately maintain the framework, we need to be very careful regarding the amount of code we include.

If applicable, please consider releasing your code as a package so that the community can still take advantage of your contributions!

@JordanchoEftimov JordanchoEftimov deleted the optimise-arr-set-and-join branch June 16, 2025 15:17
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.

3 participants