-
-
Notifications
You must be signed in to change notification settings - Fork 815
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
Faster colors #853
Faster colors #853
Conversation
bf8636d
to
70c3529
Compare
70c3529
to
6c7c238
Compare
This looks really great - thank you very much. I'd like to do a bit more testing before I approve this, but I'm definitely ok with the "regression" in functionality. |
I even have an idea of how to bring the per-component colors back, but it would need changes to |
for c in path_str[offset..].chars() { | ||
if std::path::is_separator(c) { | ||
offset += c.len_utf8(); | ||
} else { | ||
break; | ||
} | ||
} |
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.
I don't understand how this code could be triggered? Wouldn't this imply that the final path component has another path separator inside?
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.
Say the (user supplied) path is a/b///c
. parent
will be a/b
. This loop then advances the length to include a/b///
.
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! Thank you.
It can be expensive to color each path component separately, requiring a stat() call on each component. For deep hierarchies this can result in quadratic overhead. Instead, just color the path up to the basename as a directory. Fixes sharkdp#720.
6c7c238
to
13390b3
Compare
This can give a significant performance benefit:
Fixes #720. On the other hand, it does lose the distinct colors for
symlinks along the path, as you mentioned in
#720 (comment).