php-simple-console
php-simple-console copied to clipboard
Iterations calling the count function
Hi there,
A small question. Looking at the Friendica source I see they are using your Console.php code. There is however one spot in the Console.php file where a count is being used instead of calculating the array with a predefined var.
The old code:
protected function parseArgv($argv)
{
$this->executable = array_shift($argv);
$key = null;
$out = array();
for ($i = 0, $j = count($argv); $i < $j; $i++) {
This is a bit faster
protected function parseArgv($argv)
{
$this->executable = array_shift($argv);
$key = null;
$out = array();
$num_argv = count($argv);
for ($i = 0, $j = $num_argv; $i < $j; $i++) {
Would you be willing to change this in the project code so we can use a new version of it? It prevents calling the count function for each iteration.
Thanks,
Hans
I can do this change but I don't have time to test it.
If you can create a PR, I will very grateful.
Hi Asika,
Sorry to hear that, it means adding one line, altering a different one. I added the code in my initial posting but here is the complete file. I only altered the suggested ones. You can simply rename it and upload it.
I have tested it myself on my own Friendica instance. If that is enough for you then I suppose you can update it.