Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Iterations calling the count function #4

Open
hansw-nlo opened this issue Aug 3, 2021 · 3 comments
Open

Iterations calling the count function #4

hansw-nlo opened this issue Aug 3, 2021 · 3 comments

Comments

@hansw-nlo
Copy link

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

@asika32764
Copy link
Owner

I can do this change but I don't have time to test it.

If you can create a PR, I will very grateful.

@hansw-nlo
Copy link
Author

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.

Console.txt

@hansw-nlo
Copy link
Author

I have tested it myself on my own Friendica instance. If that is enough for you then I suppose you can update it.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants