-
-
Notifications
You must be signed in to change notification settings - Fork 1.5k
Open
Description
Problem
syncMarkedBlocks() currently performs:
- nested matching using
JSON.stringify(...)between_blockMapand_blockMapHelper - deduplication using
filter(...findIndex(...))
For larger phrase matrices, this increases CPU usage and creates unnecessary temporary strings.
Why It Matters
This method runs during matrix synchronization in PhraseMaker. The current approach scales poorly as matrix size grows.
Proposed Change
- Build a keyed lookup map for
_blockMapHelperrhythm refs once per call. - Replace nested stringify matching with O(1) key lookup.
- Replace quadratic dedupe with a single-pass
Set-based dedupe (preserve first occurrence order).
Scope
- File:
js/widgets/PhraseMakerGrid.js - Method:
syncMarkedBlocks(pm)
Acceptance Criteria
- Functional behavior remains unchanged.
- Ordering remains stable (first occurrence kept).
- Method avoids nested stringify equality loops and
findIndex-based dedupe. - Existing PhraseMakerGrid unit tests pass.
Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
No labels