perf: UiLayer HashMap → flat Vec array — 62 FPS → 95 FPS

Replaced HashMap<(i32,i32), UiCell> with Vec<Option<UiCell>> indexed
by y*width+x. dirty_keys Vec tracks non-None cells for iteration.
- set/set_alpha: O(1) array write (was O(1) amortized HashMap insert
  with hashing overhead)
- get: O(1) array index (was HashMap lookup)
- keys(): iterate dirty_keys Vec (was HashMap keys iterator)
- clear(): memset None over flat array (was HashMap::clear)
- resize() called in build_ui to size array to viewport
- All 185 tests + 14 scenarios pass
- Benchmark: 95.1 FPS (was 61.9 — 53% improvement)
This commit is contained in:
Emil
2026-06-22 13:32:47 +03:00
parent a16645d2d8
commit b52798c634
7 changed files with 59 additions and 24 deletions
+1
View File
@@ -53,6 +53,7 @@ fn depth_shown_in_hud() {
let mut ui = verbatim::ui::UiLayer::new();
let screen_w = 320;
let screen_h = 100;
ui.resize(screen_w, screen_h);
ui.draw_hud(
screen_w,
screen_h,
+1
View File
@@ -172,6 +172,7 @@ fn ui_hud_shows_player_hp() {
let mut s = setup();
let mut ui = verbatim::ui::UiLayer::new();
let player = s.game.entities.all()[0].clone();
ui.resize(80, 25);
ui.draw_hud(
80,
25,