ProxyLookup: Optimise in_array in isConfiguredProxy()
authorTimo Tijhof <krinklemail@gmail.com>
Sat, 31 Aug 2019 21:16:08 +0000 (22:16 +0100)
committerTimo Tijhof <krinklemail@gmail.com>
Sat, 31 Aug 2019 21:30:08 +0000 (22:30 +0100)
commita11863a0af42a360ea5eab7669b742fbc72f1b35
tree66a88db4c6803c6888abd903a9bd32b72ad3ffa7
parentb0c56c7050227d5422d3b539b9ddcc44b7bf9e5a
ProxyLookup: Optimise in_array in isConfiguredProxy()

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
includes/ProxyLookup.php