synapse/handlers/sync.py _get_rooms_changed: newly_joined_rooms is List[str] checked with `in` inside for-loop over all joined rooms (line 2252). O(J*N) where J=joined rooms, N=newly joined. Fix: use Set. 99x at J=5000.
997 B
997 B
matrix-js-sdk — CWE-407 Scan Result: CLEAN
Scanned: 2026-03-30 Source: https://github.com/matrix-org/matrix-js-sdk (depth=1)
Scan Coverage
src/models/room.ts— room timeline, member list, thread notificationssrc/models/room-state.ts— member filteringsrc/sync.ts— sync processing, toDevice event handlingsrc/filter-component.ts— event filter evaluationsrc/client.ts— client-level operationssrc/models/event-timeline-set.ts— timeline event dedupsrc/crypto/— device tracking, key verification
Findings
All .includes() / .indexOf() calls found are on:
- Small constant arrays (enum value checks, 2-5 elements)
functionalMembers(service member IDs, typically 0-2)excludedIds(small exclusion lists)cancelledKeyVerificationTxns(bounded by single sync response)
No O(N^2) patterns found in hot paths. The codebase correctly uses Map/Set for large collections and only uses Array.includes() on small, bounded arrays.