perf(ui/overview): use static strings in title and connector spans#412
Open
obchain wants to merge 1 commit into
Open
perf(ui/overview): use static strings in title and connector spans#412obchain wants to merge 1 commit into
obchain wants to merge 1 commit into
Conversation
connections_title built a mutable String from one of two static bases,
conditionally extended it with push_str, then wrapped it in format!(" {base}")
for the Span — two or three allocations per frame for content that is fully
determined by two boolean flags.
Replace with a match on (show_historic, grouped) that returns a &'static str
with the space already embedded; Span::styled accepts &'static str directly
via Into<Cow<'static, str>>, so the format!() call is also eliminated.
In the expanded-group render loop, connector is already a &'static str
(" └─ " / " ├─ "). The to_string() call that converted it to an owned
String before passing to Span::styled was unnecessary — removed.
Closes domcyrus#411
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
Closes #411
What
Two allocation patterns eliminated in
src/ui/tabs/overview.rs. All 78 lib tests pass unchanged.1.
connections_title— match on booleans instead of building a StringThe leading space is baked into each static string, eliminating the
format!(" {base}")call entirely. Saves 2–3 allocations every frame.2. Connector span in expanded-group rows
connectoris&'static str(either" └─ "or" ├─ ").Span::styledacceptsT: Into<Cow<'static, str>>, which&'static strsatisfies directly. Saves 1 allocation per visible expanded-group connection per frame.Verification