objectcache: Optimise array_map in MemcachedBagOStuff::makeKey()
authorTimo Tijhof <krinklemail@gmail.com>
Sat, 31 Aug 2019 21:38:42 +0000 (22:38 +0100)
committerTimo Tijhof <krinklemail@gmail.com>
Sat, 31 Aug 2019 21:43:21 +0000 (22:43 +0100)
commite0d817b7f6a58875782f31bb025a9df5c3ac2a33
treecbebf8f29dfeb34742bee9c2742a580f8378ac17
parentb0c56c7050227d5422d3b539b9ddcc44b7bf9e5a
objectcache: Optimise array_map in MemcachedBagOStuff::makeKey()

This can get called a lot on an average page load, optimise
a bit by using a referenced foreach iteration instead.

Using a simplified test case, I found this saves about 70% on PHP 7.2.
For 100 iterations, from ~1.5ms to ~0.4 ms.

```lang=php
$args = [ 'FooBar', 'thisthat', 4, 'foo', 12 ];
$left = 100;
foreach ($args as &$arg) {
    $arg = strtr( $arg, ' ', '_' );
    if ( strlen( $arg ) < $left || true ) {
        $arg = '#' . $arg;
    }
    $left--;
}
```

Change-Id: Ie779c4661306a6d3dc08c08671f1a36682ca1afb
includes/libs/objectcache/MemcachedBagOStuff.php