Skip to content

perf(grid): precompiled, offset-based patterns in the filter lexer (#1527, #1512) - #1607

Merged
ZhuchkaTriplesix merged 1 commit into
devfrom
issue/1527-grid-filter-engine
Oct 15, 2026
Merged

ZhuchkaTriplesix merged 1 commit into
devfrom
issue/1527-grid-filter-engine

Conversation

@ZhuchkaTriplesix

Copy link
Copy Markdown
Member

Summary

GridFilterEngine's lexer runs on every keystroke in the grid filter bar. Per token it copied the rest of the input (input.substring(i), substring(p), substring(andPos)) and built about ten RegExp objects (AND, OR, NOT, IS NULL, IN, BETWEEN, AND after BETWEEN, LIKE, comparison operators, identifiers).

The patterns are static final fields now, written without ^, and are tried with matchAsPrefix(input, offset). Nothing is copied or compiled while typing. Match boundaries and group indices are as before (\b after the keyword still looks at the next character of the same input). #1527 and #1512 describe the same code, so one PR closes both.

Not done here: #1550 (compile the predicate per row, same file) is a separate change and stays open.

Tests (not run locally; CI will)

test/features/workspace/grid_filter_tokenizer_test.dart: keyword boundaries (android is not AND, note is not NOT), symbolic && || !, operators without spaces (price>=30, name:an), IS NULL / IS NOT NULL in any case, IN / NOT IN / IN( without a space, BETWEEN, LIKE / ILIKE / NOT LIKE, and parentheses. The existing filter tests are untouched.

Closes #1527
Closes #1512

GridFilterEngine's lexer ran on every keystroke in the filter bar and, per
token, copied the rest of the input (input.substring(i) / substring(p)) and
compiled about ten RegExp objects (AND, OR, NOT, IS NULL, IN, BETWEEN, LIKE,
comparison operators, identifiers).

The patterns are static final fields without a ^ anchor and are tried with
matchAsPrefix(input, offset), so nothing is copied or compiled while typing.
Semantics are unchanged; tests pin keyword boundaries (android is not AND,
note is not NOT), operators without spaces, IS NULL, IN, BETWEEN, LIKE and
parentheses.

Closes #1527
Closes #1512
@github-actions github-actions Bot added enhancement New feature or request parser Theme parser epic label: parser performance Theme parser epic label: performance data-grid Interactive data grid, cell editor, filtering, groupings P2 Medium priority / Parity & Refactoring P3 Low priority / Polish & Enhancements labels Oct 15, 2026
@github-actions github-actions Bot added this to the 0.5.0 milestone Oct 15, 2026
@ZhuchkaTriplesix
ZhuchkaTriplesix merged commit df282f0 into dev Oct 15, 2026
15 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

data-grid Interactive data grid, cell editor, filtering, groupings enhancement New feature or request P2 Medium priority / Parity & Refactoring P3 Low priority / Polish & Enhancements parser Theme parser epic label: parser performance Theme parser epic label: performance

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant