-
Notifications
You must be signed in to change notification settings - Fork 251
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
Make tab extension lazy #684
Conversation
Makes sense to me, thanks! Just kicked of CI to verify. |
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.
Thanks, that looks like a nice win!
Also, would be nice if you can squash your commits.
@@ -346,21 +347,20 @@ pub(crate) enum TabExpandedString { | |||
NoTabs(Cow<'static, str>), | |||
WithTabs { | |||
original: Cow<'static, str>, | |||
expanded: String, | |||
expanded: OnceCell<String>, |
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.
Can we just use Option
instead of OnceCell
for this? Seems simpler.
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.
No, I don't think so: We don't have mut
access in expanded
. AFAIK, that's essentially what OnceCell
is there for.
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.
Fair enough!
e8de6a3
to
803b013
Compare
This change seems to have made |
@tgross35 ah, sorry about that. Would you be able to submit a PR, including a test for |
The change at [1] stores some data in a `OnceCell`, which made `ProgressStyle` no longer `Sync`. Fix this by changing the `OnceCell` to a `OnceLock`, and add a static test that all relevant public types are `Send` and `Sync`. [1]: console-rs#684
Sure! Done at #694 |
The change at [1] stores some data in a `OnceCell`, which made `ProgressStyle` no longer `Sync`. Fix this by changing the `OnceCell` to a `OnceLock`, and add a static test that all relevant public types are `Send` and `Sync`. [1]: #684
Running the snippet of #683 a big chunk of the time is spent in allocating a new string in
TabExpandedString
. Delaying the expanding of tabs reduces the runtime of ~100ms to ~60ms.The idea is simple: Rather than replacing
\t
with spaces immediately, this is done onceexpanded
is actually called.