Repository navigation
perf(grid): precompiled, offset-based patterns in the filter lexer (#1527, #1512) - #1607
Merged
Merged
Conversation
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
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
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 tenRegExpobjects (AND,OR,NOT,IS NULL,IN,BETWEEN,ANDafterBETWEEN,LIKE, comparison operators, identifiers).The patterns are
static finalfields now, written without^, and are tried withmatchAsPrefix(input, offset). Nothing is copied or compiled while typing. Match boundaries and group indices are as before (\bafter the keyword still looks at the next character of the same input).#1527and#1512describe 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 (androidis notAND,noteis notNOT), symbolic&&||!, operators without spaces (price>=30,name:an),IS NULL/IS NOT NULLin 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