-
Notifications
You must be signed in to change notification settings - Fork 11.6k
[12.x] Refactor the setTrustedProxyIpAddresses() method #57351
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
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 |
I will draft this until I implement the @shaedrich suggestions. |
It's now ready for review. Also, I have changed the description to match the new changes. |
There was a problem hiding this 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.
I have changed the PR title to refactor. |
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! |
Description
This PR avoid redundant calls and simplify checks by:
$request->host()
in a local$host
variable instead of calling it multiple times.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.