Skip to content

perf(grid): eliminate dynamic RegExp compilations and substring allocations in GridFilterEngine #1527

Open

Description

@ZhuchkaTriplesix

Problem

In GridFilterEngine (lib/features/workspace/grid_filter_engine.dart), tokenize and _tryMatchPredicate are triggered on every keystroke in the grid filter bar.
On every step of the tokenization loop:

  • input.substring(i) is called, allocating a new string.
  • Over 9 RegExp instances are dynamically instantiated and compiled (AND|&&, OR|||, NOT|!, IS NULL, IN, BETWEEN, LIKE, comparisons, identifiers).
    For a moderate filter query, this generates ~50 temporary string allocations and ~60 dynamic regex compilations per keystroke, causing typing latency.

Solution

  • Replace input.substring(i) with index-based checks (input.startsWith('AND', i) or codeUnitAt).
  • Match comparison operators (>=, <=, !=, <>, ==, =, >, <) using branch logic or static table rather than dynamic regex.
  • Precompile all keyword patterns into static final fields or replace with zero-allocation character scanners.

Benefits

  • Zero regex compilations during keystroke tokenization.
  • Instant feedback in grid search bar with negligible GC churn.

Activity

  1. added this to the 0.5.0 milestone on Oct 12, 2026
  2. added
    enhancementNew feature or request
    data-gridInteractive data grid, cell editor, filtering, groupings
    parserTheme parser epic label: parser
    P2Medium priority / Parity & Refactoring
    on Oct 12, 2026
  3. added a commit that references this issue on Oct 15, 2026
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

    P2Medium priority / Parity & Refactoringdata-gridInteractive data grid, cell editor, filtering, groupingsenhancementNew feature or requestparserTheme parser epic label: parserperformanceTheme parser epic label: performance

    Type

    No type

    Projects

    No projects

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions