Skip to content

Cache DefaultTheme dynamic token colors - #464

Closed
simonbs wants to merge 1 commit into
mainfrom
codex/default-theme-palette
Closed

simonbs wants to merge 1 commit into
mainfrom
codex/default-theme-palette

Conversation

@simonbs

@simonbs simonbs commented Oct 27, 2026

Copy link
Copy Markdown
Owner

DefaultTheme rebuilt a named asset UIColor for every highlighted capture. Cache its 13 token colors in immutable static properties so repeated highlighting reuses the dynamic UIColor objects. Highlight-name parsing/fallback, nil colors, font traits and public API remain unchanged; custom Theme callbacks are untouched.

Validation:

  • 19 focused permanent tests passed: DefaultTheme (5), complete styles (7), syntax highlighting (1), background rendering (3), batch undo (1), line endings (2). Adds palette/fallback/trait coverage and extends background highlighting coverage.
  • 2 local-only editing checks passed for wrapped/unwrapped insert/delete, split/join, undo/redo, and caret/content-height geometry against fresh editors. Their initial failure was corrected in the harness to reproduce UIKit's nonempty selection before deleteBackward.
  • 1 local-only Release comparison passed, checking full attributed-string equality on every trial. SwiftLint and git diff --check passed.

Release full-line highlighting on iOS 27.2 Simulator, comparing this implementation against an unchanged copy of main's DefaultTheme at df9b56f in the same binary. One warmup per variant, seven measured trials, alternating order; parsing and initial attributed-string construction excluded. Median milliseconds:

Input Main Cached
Normal JSON, 49 bytes 0.090 0.044
Representative long JSON line, 58,901 bytes 2.315 1.282
Dense JSON, 262,141 bytes 371.520 179.346
Dense JSON, 1,048,573 bytes 1,660.155 793.234

The 1 MiB ranges were 1,551.012–1,944.452 ms before and 773.944–881.134 ms after. These are synchronous Simulator highlighting measurements, not physical-device/compositor timings. Dense lines remain expensive. This does not establish a RunestoneEditor speedup: its custom theme already caches colors. Fixtures and benchmark instrumentation remain local.

@simonbs simonbs closed this Oct 27, 2026
@simonbs
simonbs deleted the codex/default-theme-palette branch October 27, 2026 12:39
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant