Skip to content

Commit dcab051

Browse files
committed
update code
1 parent 9e08c51 commit dcab051

File tree

5 files changed

+8
-58
lines changed

5 files changed

+8
-58
lines changed

frontends/rioterm/src/renderer/mod.rs

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -952,8 +952,6 @@ impl Renderer {
952952
context_manager: &mut ContextManager<EventProxy>,
953953
focused_match: &Option<RangeInclusive<Pos>>,
954954
) -> Option<crate::context::renderable::WindowUpdate> {
955-
let start = std::time::Instant::now();
956-
957955
let grid = context_manager.current_grid_mut();
958956
let active_key = grid.current;
959957
let grid_scaled_margin = grid.get_scaled_margin();
@@ -1128,7 +1126,6 @@ impl Renderer {
11281126
continue;
11291127
}
11301128
TerminalDamage::Full => {
1131-
println!("full");
11321129
// Full damage, render everything
11331130
}
11341131
TerminalDamage::Partial(lines) => {
@@ -1385,8 +1382,6 @@ impl Renderer {
13851382
None
13861383
};
13871384

1388-
let duration = start.elapsed();
1389-
println!("[renderer] render took {:?}", duration);
13901385
window_update
13911386
}
13921387

frontends/rioterm/src/screen/mod.rs

Lines changed: 0 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -3205,7 +3205,6 @@ impl Screen<'_> {
32053205
}
32063206

32073207
pub fn render(&mut self) -> Option<crate::context::renderable::WindowUpdate> {
3208-
let screen_render_start = std::time::Instant::now();
32093208
let is_search_active = self.search_active();
32103209
if is_search_active {
32113210
if let Some(history_index) = self.search_state.history_index {
@@ -3298,14 +3297,7 @@ impl Screen<'_> {
32983297
}
32993298
}
33003299

3301-
let sugarloaf_start = std::time::Instant::now();
33023300
self.sugarloaf.render();
3303-
let sugarloaf_duration = sugarloaf_start.elapsed();
3304-
let total_duration = screen_render_start.elapsed();
3305-
println!(
3306-
"[screen] sugarloaf.render: {:?} | total: {:?}",
3307-
sugarloaf_duration, total_duration
3308-
);
33093301

33103302
// Mark as dirty if we need continuous rendering (e.g., indeterminate progress bar)
33113303
if self.renderer.needs_redraw() {
@@ -3334,13 +3326,6 @@ impl Screen<'_> {
33343326
.blink_cursor(self.renderer.config_blinking_interval);
33353327
}
33363328

3337-
// let _screen_render_duration = screen_render_start.elapsed();
3338-
// if self.renderer.enable_performance_logging {
3339-
// println!(
3340-
// "[PERF] Screen render() total: {:?}\n",
3341-
// screen_render_duration
3342-
// );
3343-
// }
33443329
window_update
33453330
}
33463331

sugarloaf/src/renderer/mod.rs

Lines changed: 0 additions & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -1010,7 +1010,6 @@ impl Renderer {
10101010
}
10111011
}
10121012

1013-
let t_after_graphics = std::time::Instant::now();
10141013
// Now set up rendering - borrow comp and caches
10151014
let comp = &mut self.comp;
10161015
let caches = (&mut self.images, &mut self.glyphs);
@@ -1050,13 +1049,6 @@ impl Renderer {
10501049
let take_count = selected_lines
10511050
.map_or(lines_to_process.len(), |range| range.end - range.start);
10521051

1053-
let t_lines_start = std::time::Instant::now();
1054-
let mut perf_cache_lookup_ns: u64 = 0;
1055-
let mut perf_draw_run_ns: u64 = 0;
1056-
let mut perf_glyph_build_ns: u64 = 0;
1057-
let mut perf_empty_runs: u32 = 0;
1058-
let mut perf_text_runs: u32 = 0;
1059-
10601052
for (_line_idx, line) in lines_to_process
10611053
.iter()
10621054
.enumerate()
@@ -1093,7 +1085,6 @@ impl Renderer {
10931085
// Fast path: empty run (blanks/spaces) — just advance
10941086
// and optionally paint background/cursor
10951087
if run.glyphs.is_empty() {
1096-
perf_empty_runs += 1;
10971088
let advance = cell_width * char_width;
10981089
let run_x = px;
10991090
px += advance;
@@ -1136,26 +1127,22 @@ impl Renderer {
11361127
continue;
11371128
}
11381129

1139-
perf_text_runs += 1;
11401130
let font = run.span.font_id;
11411131
let run_x = px;
11421132

11431133
// Use pre-computed cache key — no String allocation needed
1144-
let t1 = std::time::Instant::now();
11451134
let cached_result = if run.cache_key != 0 {
11461135
self.text_run_manager.get_cached_data_by_key(run.cache_key)
11471136
} else {
11481137
CacheResult::Miss
11491138
};
1150-
perf_cache_lookup_ns += t1.elapsed().as_nanos() as u64;
11511139

11521140
match cached_result {
11531141
CacheResult::Hit {
11541142
glyphs: cached_glyphs,
11551143
..
11561144
} => {
11571145
// Use cached glyph data but need to render
1158-
let tg = std::time::Instant::now();
11591146
glyphs.clear();
11601147
for shaped_glyph in cached_glyphs.iter() {
11611148
let x = px;
@@ -1173,7 +1160,6 @@ impl Renderer {
11731160
y,
11741161
});
11751162
}
1176-
perf_glyph_build_ns += tg.elapsed().as_nanos() as u64;
11771163

11781164
// Render using cached glyph data
11791165
let style = TextRunStyle {
@@ -1218,7 +1204,6 @@ impl Renderer {
12181204
);
12191205
}
12201206

1221-
let td = std::time::Instant::now();
12221207
comp.draw_run(
12231208
&mut session,
12241209
Rect::new(run_x, py, px - run_x, 1.),
@@ -1227,7 +1212,6 @@ impl Renderer {
12271212
&glyphs,
12281213
order,
12291214
);
1230-
perf_draw_run_ns += td.elapsed().as_nanos() as u64;
12311215
}
12321216
CacheResult::Miss => {
12331217
// No cached data - need to shape and render from scratch
@@ -1316,7 +1300,6 @@ impl Renderer {
13161300
);
13171301
}
13181302

1319-
let td = std::time::Instant::now();
13201303
comp.draw_run(
13211304
&mut session,
13221305
Rect::new(run_x, py, px - run_x, 1.),
@@ -1325,7 +1308,6 @@ impl Renderer {
13251308
&glyphs,
13261309
order,
13271310
);
1328-
perf_draw_run_ns += td.elapsed().as_nanos() as u64;
13291311
}
13301312
}
13311313

@@ -1379,18 +1361,6 @@ impl Renderer {
13791361
// Advance line_y for the next line
13801362
line_y += line_height;
13811363
}
1382-
1383-
let t_lines_total = t_lines_start.elapsed();
1384-
let _t_graphics = t_after_graphics.elapsed() - t_lines_total;
1385-
println!(
1386-
"[draw_layout] lines: {:?} | empty: {} text: {} | cache: {}µs glyphs: {}µs draw_run: {}µs",
1387-
t_lines_total,
1388-
perf_empty_runs,
1389-
perf_text_runs,
1390-
perf_cache_lookup_ns / 1000,
1391-
perf_glyph_build_ns / 1000,
1392-
perf_draw_run_ns / 1000,
1393-
);
13941364
}
13951365
}
13961366

sugarloaf/src/renderer/positioning_tests.rs

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -74,9 +74,10 @@ impl PositioningTestHelper {
7474

7575
if use_cache {
7676
// Try to get cached data
77-
let cached_result = self
78-
.text_run_manager
79-
.get_cached_data(text, font_id, font_size);
77+
let key = crate::font::text_run_cache::create_text_run_key(
78+
text, font_id, font_size,
79+
);
80+
let cached_result = self.text_run_manager.get_cached_data_by_key(key);
8081

8182
match cached_result {
8283
CacheResult::Hit {
@@ -162,8 +163,9 @@ impl PositioningTestHelper {
162163
}
163164

164165
// Cache the shaped data for future use
165-
self.text_run_manager.cache_shaping_data(
166-
text,
166+
let key = crate::font::text_run_cache::create_text_run_key(text, 0, 12.0);
167+
self.text_run_manager.cache_shaping_data_by_key(
168+
key,
167169
0, // font_id
168170
12.0, // font_size
169171
shaped_glyphs,

sugarloaf/src/renderer/text_run_manager.rs

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -5,9 +5,7 @@
55
//
66
// Unified text run manager - replaces separate line cache and shaping cache
77

8-
use crate::font::text_run_cache::{
9-
create_cached_text_run, ShapedGlyph, TextRunCache,
10-
};
8+
use crate::font::text_run_cache::{create_cached_text_run, ShapedGlyph, TextRunCache};
119
use std::sync::Arc;
1210
use tracing::debug;
1311

0 commit comments

Comments
 (0)