Closed WyriHaximus closed 4 years ago
Did you noticed some performances improvement with that change ?
@clue @edhelas Haven't ran any benchmarks against it. But essentially this should save us a function call wrapping another function call. Unless PHP has changed something, optimising this in a way it doesn't impact as much as it used to do this is still aesthetically more please IMHO.
@clue @edhelas on run the following benchmark using phpbench:
<?php
namespace foo {
/**
* @Revs(1000)
* @Iterations(100)
*/
class MixedBench
{
private $f;
public function __construct()
{
$this->f = function () {
return true;
};
}
public function benchCallUserFunc()
{
\call_user_func($this->f);
}
public function benchPHP7()
{
($this->f)();
}
}
}
The results show a slightly faster execution when calling it directly:
With PHP 7 we can call callables directly rather then wrap it in a costly extra function call.