perf(mongodb): zero-allocation JSON path builder and eliminate per-node RegExp compilation #1525
Copy link
Copy link
Open
Labels
P2Medium priority / Parity & RefactoringMedium priority / Parity & RefactoringbackendBackend database driver execution and queriesBackend database driver execution and queriesconnectionsDatabase connections, URI parsing, poolsDatabase connections, URI parsing, poolsenhancementNew feature or requestNew feature or requestperformanceTheme parser epic label: performanceTheme parser epic label: performance
Milestone
Description
Problem
In MongoDocumentTreeView (lib/features/mongodb/mongo_document_tree_view.dart), appendJsonPath(parentPath, keyOrIndex) instantiates RegExp(r'^[a-zA-Z_$][a-zA-Z0-9_$]*$') inside the function on every single node of a document tree.
For 1,000 documents with 20 fields each, this results in 20,000 regex compilations and matcher allocations on every render.
Solution
- Replace runtime RegExp construction with a zero-allocation character validation helper using
codeUnitAt. - Cache or precompile static pattern if regex is retained.
Benefits
- 0 RegExp allocations during MongoDB tree traversal.
- ~15-20x faster path construction for nested documents.
Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
P2Medium priority / Parity & RefactoringMedium priority / Parity & RefactoringbackendBackend database driver execution and queriesBackend database driver execution and queriesconnectionsDatabase connections, URI parsing, poolsDatabase connections, URI parsing, poolsenhancementNew feature or requestNew feature or requestperformanceTheme parser epic label: performanceTheme parser epic label: performance
Activity