You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
perf(mongodb): single-pass tokenizer in MqlParser._normalizeJsObject eliminating repeated string copying #1539
In MqlParser._normalizeJsObject (lib/features/mongodb/mql_parser.dart):
Runs three replaceAllMapped passes with dynamic RegExps.
Replaces string literals with placeholders (@@@STR_0@@@, @@@STR_1@@@).
Iterates over placeholders with processed = processed.replaceAll('@@@STR_$i@@@', strings[i]).
For a query containing 50 strings, replaceAll creates 50 complete copies of the entire query string in heap.
Solution
Replace the multi-pass placeholder mechanism with a single-pass tokenizer/scanner streaming normalized JSON into a StringBuffer.
Quote keys and preserve string literals in one linear scan (N)$ without intermediate query re-allocations.
Benefits
Single linear pass (N)$ with zero repeated string cloning.
Significantly faster MQL parsing for batch inserts and complex queries.
Fixed on dev by e62dfa7: fix(mongodb): one-pass normalisation of mongosh object literals (#1513, #1539) (#1661). It reaches main with the next dev to main merge (closed after checking the code and its tests).
Activity
fix(mongodb): one-pass normalisation of mongosh object literals (#1513,
docs(changelog): today's entries; test: calc bar test after #1674 (de…
ZhuchkaTriplesix commentedon Oct 25, 2026
Fixed on dev by e62dfa7: fix(mongodb): one-pass normalisation of mongosh object literals (#1513, #1539) (#1661). It reaches main with the next dev to main merge (closed after checking the code and its tests).