Skip to content

Make missing-style Debug warning opt-in to avoid regressing debug build perf - #9

Open
matrush wants to merge 1 commit into
smittytone:mainfrom
matrush:main
Open

matrush wants to merge 1 commit into
smittytone:mainfrom
matrush:main

Conversation

@matrush

@matrush matrush commented Jun 22, 2026 •

Copy link
Copy Markdown

Summary

Theme.applyStyleToString() emitted a #if DEBUG print() for every token whose style class is absent from the theme. Unstyled classes are normal theming behaviour — e.g. hljs-operator intentionally inherits the default colour under atom-one-light/atom-one-dark — so this fired thousands of times per highlighting pass (~5,585 prints / ~167ms in the reported case), spamming the console and noticeably degrading Debug-mode highlighting performance.

This implements: gate the warning behind an opt-in flag rather than removing it, so the diagnostic is still available when developing a custom theme.

Changes

  • Add public var logsMissingStyles: Bool = false to Theme.
  • Only emit the WARNING MISSING STYLE… print when logsMissingStyles is true (still #if DEBUG-gated, so Release builds are unchanged).
  • Document the flag in the README and add a usage example.
  • Add a CHANGELOG entry and bump the version to 3.1.1.

Usage

highlighter.theme.logsMissingStyles = true   // off by default

Closes #8.

🤖 Generated with Claude Code

…ld perf

The Theme.applyStyleToString() method emitted a DEBUG print() for every
token whose style class is absent from the theme. Unstyled classes (eg.
hljs-operator under atom-one-light/dark) are normal theming behaviour, so
this fired thousands of times per highlighting pass, spamming the console
and noticeably slowing Debug-mode highlighting.

Gate the warning behind a new opt-in Theme.logsMissingStyles flag
(default false). Document it in the README and CHANGELOG, and bump the
version to 3.1.1.


Claude-Session: https://claude.ai/code/session_01URhepimagEqZ2kCNzyQcYU

Co-authored-by: Claude <noreply@anthropic.com>
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.

DEBUG print() per token for unstyled classes (e.g. hljs-operator with atom-one) — console spam + slow Debug highlighting

1 participant