This is called on all page loads by WebRequest::getIP(),
from Setup.php.
Strict in_array can easily make it 4 times faster (reduce by 75%).
For example, with an array containing 5 short strings and looking
up a 6th similar string that is not in the list, repeated 100x:
loose: 2.410 ms, 2.731 ms, 2.367 ms
strict: 0.649 ms, 0.668 ms, 0.653 ms
The larger the array to search through, the bigger the difference
becomes as it speeds up each internal comparison.
(PHP 7.2.20)
Bug: T189966
Change-Id: I6742dfa0a6d44b15294695b15ffe4885cb6a5310
*/
public function isConfiguredProxy( $ip ) {
// Quick check of known singular proxy servers
- if ( in_array( $ip, $this->proxyServers ) ) {
+ if ( in_array( $ip, $this->proxyServers, true ) ) {
return true;
}