Skip to content

Conversation

AhmedAlaa4611
Copy link
Contributor

@AhmedAlaa4611 AhmedAlaa4611 commented Oct 11, 2025

Description

This PR avoid redundant calls and simplify checks by:

  • Storing $request->host() in a local $host variable instead of calling it multiple times.
  • Replacing repeated str_ends_with($host, '.on-forge.com') || str_ends_with($host, '.on-vapor.com') checks with a single $isForgeOrVapor variable.

This reduces duplication and makes the intent of the code clearer without changing its behavior.

@tontonsb
Copy link
Contributor

So what's the performance difference? Is it in memory usage or in speed? I mean you've introduced a new variable that will have to be refcounted, garbagecollected and so on.

@AhmedAlaa4611
Copy link
Contributor Author

So what's the performance difference? Is it in memory usage or in speed? I mean you've introduced a new variable that will have to be refcounted, garbagecollected and so on.

Instead of calling the host() method multiple times just call it once.

@AhmedAlaa4611
Copy link
Contributor Author

I will draft this until I implement the @shaedrich suggestions.

@AhmedAlaa4611 AhmedAlaa4611 marked this pull request as draft October 12, 2025 07:59
@AhmedAlaa4611 AhmedAlaa4611 marked this pull request as ready for review October 12, 2025 08:14
@AhmedAlaa4611
Copy link
Contributor Author

It's now ready for review. Also, I have changed the description to match the new changes.

Copy link
Collaborator

@GrahamCampbell GrahamCampbell left a comment

Choose a reason for hiding this comment

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

This makes zero performance difference in the real world.

@AhmedAlaa4611 AhmedAlaa4611 changed the title [12.x] Micro performance improvement [12.x] Refactor the setTrustedProxyIpAddresses() method Oct 12, 2025
@AhmedAlaa4611
Copy link
Contributor Author

This makes zero performance difference in the real world.

I have changed the PR title to refactor.

@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!

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.

5 participants