Skip to content

Memoize all of the significant calls in Git::Status #729

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

Merged
merged 1 commit into from
Jun 1, 2024

Conversation

nevinera
Copy link
Contributor

@nevinera nevinera commented Jun 1, 2024

When the status has many entries, there were substantial inefficiencies in this class - calling predicates like changed?(filename) would iterate the status, constructing a transient changed subhash, then test that subhash to see if the file in question was in it (for example).

After this change, it will keep those sub-hashes for reuse on the Status instance, as well as downcased versions if they happen to get requested (by case-insensitive calls).

When the status has many entries, there were substantial inefficiencies
in this class - calling predicates like `changed?(filename)` would
iterate the status, constructing a transient `changed` subhash, then
test that subhash to see if the file in question was in it (for
example).

After this, it will _keep_ those sub-hashes for reuse on the Status
instance, as well as downcased versions if they happen to get requested
(by case-insensitive calls).
@nevinera nevinera marked this pull request as ready for review June 1, 2024 04:07
Copy link
Member

@jcouball jcouball left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes. I can see what you said about the complexity. But this is great! Thank you again.

@jcouball jcouball merged commit 749a72d into ruby-git:master Jun 1, 2024
7 checks passed
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

Successfully merging this pull request may close these issues.

2 participants