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

perf: scan: preallocate and reuse a single PathBuf #6387

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

poliorcetics
Copy link
Contributor

Description

To improve performances, reuse a single allocation in ScanAncestors::scan()

Motivation and Context

Testing on a fairly deep path (7 folders), this makes a .marker dir search go from ~1ms to ~600µs somewhat consistently. Since starship is run extremely often, I think any kind of perf improvement (for notably the case where there is no .marker) is nice.

Here it makes the code longer, and probably a little more complex, but I don't think it's hard to understand by any means, especially with the comments

Screenshots (if appropriate):

How Has This Been Tested?

  • I have tested using MacOS
  • I have tested using Linux
  • I have tested using Windows

Checklist:

  • I have updated the documentation accordingly.
  • I have updated the tests accordingly.

The tests must not be updated, else it means I broke something

src/context.rs Outdated Show resolved Hide resolved
src/context.rs Outdated Show resolved Hide resolved
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