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

optimize Git plugin’s grename logic by reducing if conditions #9239

Closed
wants to merge 1 commit into from

Conversation

LucasLarson
Copy link
Contributor

Standards checklist:

  • The PR title is descriptive.
  • The PR doesn't replicate another PR which is already open.
  • I have read the contribution guide and followed all the instructions.
  • The code follows the code style guide detailed in the wiki.
  • The code is mine or it's from somewhere with an MIT-compatible license.
  • The code is efficient, to the best of my ability, and does not waste computer resources.
  • The code is stable and I have tested it myself, to the best of my abilities.

Changes:

This is an optimization. The function to rename a Git branch using @ujwaldhakal’s grename (#8622, e8609b8) requires both arguments $1 and $2, but the existence of $2 occurs only when $1 exists. Only one check for the existence of $2 (the new name of the branch) is needed.

The function to rename a branch using `grename`
requires both arguments `$1` and `$2`, but `$2`
requires the existence of `$1`. Only one check is
needed.
@ohmyzsh ohmyzsh bot added Area: plugin Issue or PR related to a plugin Plugin: git labels Sep 6, 2020
@ujwaldhakal
Copy link
Contributor

Thanks, it looks good !

@mcornella
Copy link
Member

This is more frail ($1 might be empty string) and it's not worth the risk for the null benefits of this optimitzation. Thanks for your contribution though.

@mcornella mcornella closed this Oct 10, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Area: plugin Issue or PR related to a plugin
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants