notedeck

One damus client to rule them all
git clone git://jb55.com/notedeck
Log | Files | Refs | README | LICENSE

commit 32923abfc21e8f82f5eca0c46b5f6ceee72e7b6b
parent c944cac810035981ebe348d55c31a17a63e2f1ed
Author: William Casarin <jb55@jb55.com>
Date:   Mon, 22 Apr 2024 08:58:30 -0700

perf: profiling note content rendering

Made some small speed improvements

Signed-off-by: William Casarin <jb55@jb55.com>

Diffstat:
Msrc/ui/note/contents.rs | 21++++++++++++++-------
1 file changed, 14 insertions(+), 7 deletions(-)

diff --git a/src/ui/note/contents.rs b/src/ui/note/contents.rs @@ -53,6 +53,9 @@ fn render_note_preview( id: &[u8; 32], _id_str: &str, ) -> egui::Response { + #[cfg(feature = "profiling")] + puffin::profile_function!(); + let note = if let Ok(note) = app.ndb.get_note_by_id(txn, id) { // TODO: support other preview kinds if note.kind() == 1 { @@ -123,6 +126,9 @@ fn render_note_contents( match block.blocktype() { BlockType::MentionBech32 => match block.as_mention().unwrap() { Mention::Pubkey(npub) => { + #[cfg(feature = "profiling")] + puffin::profile_scope!("pubkey contents"); + ui.horizontal(|ui| { let profile = damus.ndb.get_profile_by_pubkey(txn, npub.pubkey()).ok(); @@ -154,17 +160,14 @@ fn render_note_contents( } _ => { - ui.colored_label(colors::PURPLE, "@"); - ui.colored_label(colors::PURPLE, &block.as_str()[4..16]); + ui.colored_label(colors::PURPLE, format!("@{}", &block.as_str()[4..16])); } }, BlockType::Hashtag => { - ui.horizontal(|ui| { - ui.spacing_mut().item_spacing.x = 0.0; - ui.colored_label(colors::PURPLE, "#"); - ui.colored_label(colors::PURPLE, block.as_str()); - }); + #[cfg(feature = "profiling")] + puffin::profile_scope!("hashtag contents"); + ui.colored_label(colors::PURPLE, format!("#{}", block.as_str())); } BlockType::Url => { @@ -174,6 +177,8 @@ fn render_note_contents( images.push(url); } else { */ + #[cfg(feature = "profiling")] + puffin::profile_scope!("url contents"); ui.add(Hyperlink::from_label_and_url( RichText::new(block.as_str()).color(colors::PURPLE), block.as_str(), @@ -182,6 +187,8 @@ fn render_note_contents( } BlockType::Text => { + #[cfg(feature = "profiling")] + puffin::profile_scope!("text contents"); ui.label(block.as_str()); }