You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I added the following to GitElephant\Command\Caller\Caller::execute method to see how GitElephant calls the underlying Git binary:
print $cmd.'<br />';
And found out that whenever GitElephant\Repository::getBranches is called, the command git branch will be executed the same number of times as the number of local branches plus one. So if I have four branches, the command will be executed five times. Not so optimized.
Diving into the code, I found out that the following method calls happen when calling getBranches:
BranchCommand::listBranches is executed. This is the first git branch command execution.
For each output line, Branch::createFromOutputLine is called.
In Branch::createFromOutputLine, constructor of Branch class is called.
The constructor calls Branch::createFromCommand method.
Inside Branch::createFromCommand method, BranchCommand::listBranches is executed. This will be repeated for each output line processed in step 2 above.
Branch::createFromCommand method will call Branch::parseOutputLine. Returning to the constructor and then returning to Branch::createFromOutputLine method, Branch::parseOutputLine is called again using output line passed from Repository::getBranches method.
In step 6, the parseOutputLine method is called twice, which can be reduced to one if we can make the Branch::createFromOutputLine method call the Branch class constructor without calling Branch::createFromCommand because the output line needed to be parsed is already been provided as a parameter of Branch::createFromOutputLine.
Using version 1.1.0 via composer.
Please comment.
The text was updated successfully, but these errors were encountered:
I added the following to
GitElephant\Command\Caller\Caller::execute
method to see how GitElephant calls the underlying Git binary:And found out that whenever
GitElephant\Repository::getBranches
is called, the commandgit branch
will be executed the same number of times as the number of local branches plus one. So if I have four branches, the command will be executed five times. Not so optimized.Diving into the code, I found out that the following method calls happen when calling getBranches:
BranchCommand::listBranches
is executed. This is the firstgit branch
command execution.Branch::createFromOutputLine
is called.Branch::createFromOutputLine
, constructor ofBranch
class is called.Branch::createFromCommand
method.Branch::createFromCommand
method,BranchCommand::listBranches
is executed. This will be repeated for each output line processed in step 2 above.Branch::createFromCommand
method will callBranch::parseOutputLine
. Returning to the constructor and then returning toBranch::createFromOutputLine
method,Branch::parseOutputLine
is called again using output line passed fromRepository::getBranches
method.In step 6, the
parseOutputLine
method is called twice, which can be reduced to one if we can make theBranch::createFromOutputLine
method call theBranch
class constructor without callingBranch::createFromCommand
because the output line needed to be parsed is already been provided as a parameter ofBranch::createFromOutputLine
.Using version 1.1.0 via composer.
Please comment.
The text was updated successfully, but these errors were encountered: