-
Notifications
You must be signed in to change notification settings - Fork 1.9k
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
Optimize CommandRunner and Commands #4683
Conversation
e1abccc
to
b24423e
Compare
@MGatner this optimization made all test cases of |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Glad you cracked this egg! Moving the discovery to the constructor could cause some people problems, but generally I think it is a better design. Maybe see if we can get another review from @lonnieezell or @samsonasik on that point? Otherwise just a couple of tweaks.
I typically prefer not to do things like that in a constructor but in this case I don't see a problem with it. Commands aren't something that are called all of the time, and testing is where that has the tendency to be the biggest issue. But that's why we're moving it now so it looks good to me! |
I have pondered on this and I don't think moving discovery to the constructor would give us problems. Discovery essentially fills up the $commands array prop with the discovered commands. Current design shows that every invoke of run we call discoverCommands which in turn returns early if the $commands prop is already populated. So this prop is never overwritten. Moving the discovery at constructor initialization would be a big gain, as the tests demonstrate. |
b24423e
to
8f71558
Compare
Checklist: