Skip to content

perf(theme): eliminate duplicate string scanning and StringBuffer allocations in stripJsonc #1360

Closed

Description

@ZhuchkaTriplesix

Summary

In lib/core/theme/parser/jsonc_preprocessor.dart (lines 11–15, 57–90):

if (ch == '"') {
  out.write(_copyStringLiteral(input, i));
  i = _skipStringLiteral(input, i);
  continue;
}

When encountering a quote ("):

  1. _copyStringLiteral(input, i) iterates character-by-character through input, writing to an intermediate StringBuffer and returning a new String.
  2. Immediately after, _skipStringLiteral(input, i) scans the exact same characters in input a second time to determine the ending offset.

For VS Code themes containing thousands of tokens and hex color strings (50–150 KB JSONC files), this doubles character scanning work and creates thousands of short-lived StringBuffer and String allocations during theme parsing.

Proposed Solution

  1. Find the closing quote of a string literal in a single scan pass.
  2. Directly write the slice out.write(input.substring(start, end)) to avoid creating intermediate StringBuffer instances for each string literal.

Acceptance Criteria

  • String literals in JSONC are scanned in a single pass without redundant character loops.
  • Theme JSONC parsing is faster with reduced GC allocations.
  • All existing stripJsonc unit tests pass.

Activity

  1. added
    themeTheming, colors, VS Code themes
    performanceTheme parser epic label: performance
    coreCore library logic and services
    P3Low priority / Polish & Enhancements
    on Oct 10, 2026
  2. ZhuchkaTriplesix commented on Oct 11, 2026

    @ZhuchkaTriplesix
    MemberAuthor

    Done in #1400 (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 & EnhancementscoreCore library logic and servicesperformanceTheme 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