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(dotnet): fail faster in the dotnet module #1034

Merged
merged 1 commit into from Apr 3, 2020
Merged

perf(dotnet): fail faster in the dotnet module #1034

merged 1 commit into from Apr 3, 2020

Conversation

davidkna
Copy link
Member

Description

For finding the necessary files to determine the version and if the module should be enabled the dotnet module is currently iterating through all files in the current directory (O(n)) to find relevant files.

This PR makes the module exit early in case the relevant files aren't present and only does the work of finding these files if they are present.

Possible breakage:
estimate_dotnet_version is case insentive but context.is_match() is not.

Motivation and Context

Tested with hyperfine in starship/src/modules:

before:
starship module dotnet 63.9 ms ± 4.6 ms

after:
starship module dotnet 23.9 ms ± 2.5 ms

Types of changes

  • Bug fix (non-breaking change which fixes an issue)
  • New feature (non-breaking change which adds functionality)
  • Breaking change (fix or feature that would cause existing functionality to not work as expected)

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.

@davidkna
Copy link
Member Author

It looks like #886 wasn't fixed after all.

@andytom andytom changed the title perf: fail faster in the dotnet module perf(dotnet): fail faster in the dotnet module Mar 31, 2020
@matchai
Copy link
Member

matchai commented Apr 3, 2020

Thank you for the performance improvement, @davidkna! 😄

@matchai matchai merged commit 55503bb into starship:master Apr 3, 2020
@davidkna davidkna deleted the dotnet-fast-fail branch April 3, 2020 17:38
dagbrown pushed a commit to dagbrown/starship that referenced this pull request Oct 22, 2021
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.

None yet

3 participants