java-topology/defects/endless-sky-0001/test
russell@unturf.com 179cfdc6fb endless-sky-0001: ByGivenOrder comparator std::find() O(N) per comparison, 338x
Defect: ByGivenOrder<T> uses std::find() on a vector for every comparison,
making it O(N) per call. Used as std::map comparator in MainPanel.cpp for
outfit scanning, giving O(O * C * log C) total scan operations where C is
category count and O is outfit count.

Fix: replace vector + std::find with unordered_map<T, size_t> for O(1)
index lookup per comparison. 338x fewer scan operations measured at
C=500 O=1000. Correctness verified: sort order and map iteration order
match original for known values, unknown values, and mixed inputs.

MOAD-0002: GameData has 80 static members (god object), typical for
single-threaded game architecture. Not a fixable defect.
MOAD-0003: CLEAN. thread_local used appropriately for Random/Files/CollisionSet.
MOAD-0004: CLEAN. No credentials or secrets in a space trading game.
MOAD-0005: CLEAN. Single-threaded game, no concurrent cache access.
2026-03-31 12:27:54 -04:00
..
test endless-sky-0001: ByGivenOrder comparator std::find() O(N) per comparison, 338x 2026-03-31 12:27:54 -04:00
test_by_given_order.cpp endless-sky-0001: ByGivenOrder comparator std::find() O(N) per comparison, 338x 2026-03-31 12:27:54 -04:00