Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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.
Might be worth adding a comment here, so one isn’t tempted to refactor to the simpler
dirname
approach in the future.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.
Another thought: Is a
while
loop faster than recursion? Don’t know what the overhead of calling functions in fish is.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.
Well, it doesn't seem to make much difference when using the following version:
I even got mixed results when I ran it more than once. Sometimes, this version is slower by 2~3 ms.
Keep in mind I'm 40-ish directories deep in the directory tree. When you're in the same directory, even the original version using
dirname
runs at around 200 microseconds. 🤓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.
Ah, comments, yeah, let me come up with a good excuse to avoid having to write one.
Got it!
It's fishier (as in more idiomatic in Fish) to use builtins, as they're usually faster and consistent across OSes, therefore one shouldn't be tempted to switch to an external command (which may not even be available in the host system).