Skip to content

Cache theme::resolve_theme() result in render — avoid unconditional recomputation per frame #207

Description

@MasonRhodesDev

Context

Render architecture audit from #203. theme::resolve_theme(window, theme_mode) is called unconditionally at the top of AnotherOneApp::render on every frame — at 16ms ticks during active use, that is ~62 calls per second for a value that changes only when the user explicitly toggles the theme.

Location

app/src/app.rs — first lines of AnotherOneApp::render, immediately after control_registry.borrow_mut().clear().

What to do

Cache the resolved theme on AnotherOneApp (e.g. cached_theme: Option<Theme>). At the top of render, only call resolve_theme when theme_mode has changed since the last frame (compare against a stored last_theme_mode). The terminal snapshot rebuild that also triggers on theme change (a few lines later) is already gated on the result — keep that gate.

Small change, zero architectural risk, measurable reduction in per-frame work.

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't working

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions