Skip to content

perf(theme): cache tokenColorsHash on QueryaTheme to eliminate Object.hashAll in QueryaCodeEditor.build() #1353

Closed

Description

@ZhuchkaTriplesix

Summary

In lib/core/editor/querya_code_editor.dart (lines 148, 296–298) and lib/core/editor/syntax_highlight_service.dart (lines 63–67):

  • During every build pass of QueryaCodeEditor:
    final tokenHash = Object.hashAll(queryaTheme.tokenColors);
  • In SyntaxHighlightService.createPair:
    Object.hash(language, queryaTheme.editor, Object.hashAll(queryaTheme.tokenColors))

A full VS Code theme (imported or built-in) typically contains 100–300+ TokenColorRule objects. Calling Object.hashAll on a 300-element list on every build of the code editor (which can trigger on cursor blinking, selection updates, or ancestor rebuilds) iterates through every rule to compute hash codes.

Proposed Solution

  1. Compute and store final int tokenColorsHash once on QueryaTheme during construction/parsing.
  2. Replace Object.hashAll(queryaTheme.tokenColors) in QueryaCodeEditor and SyntaxHighlightService with queryaTheme.tokenColorsHash.

Acceptance Criteria

  • QueryaTheme caches the precomputed hash of its tokenColors.
  • QueryaCodeEditor.build() performs an (1)$ integer comparison instead of iterating through all token rules.

Activity

  1. added
    themeTheming, colors, VS Code themes
    editorCode/SQL editor
    performanceTheme parser epic label: performance
    P3Low priority / Polish & Enhancements
    on Oct 10, 2026
  2. added this to the Theme system milestone on Oct 10, 2026
  3. ZhuchkaTriplesix commented on Oct 11, 2026

    @ZhuchkaTriplesix
    MemberAuthor

    Done in #1401 (merged into dev).

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    P3Low priority / Polish & EnhancementseditorCode/SQL editorperformanceTheme parser epic label: performancethemeTheming, colors, VS Code themes

    Type

    No type

    Projects

    No projects

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions