mirror of
https://github.com/rommapp/romm.git
synced 2026-11-29 01:58:41 +01:00
_parse_gamelist_xml read the whole file, ran two regex rewrites over it and built a tree for the entire document before touching a single game. On a platform with thousands of entries that tree dominates the scan's memory, and it is discarded as soon as the per-game dict is built. Stream top-level game/folder elements with iterparse instead, clearing each once consumed. Measured on a synthetic 4.8 MB gamelist with 10,703 games, peak allocation drops from 33.3 MB to 3.4 MB. ES-DE writes an <alternativeEmulator> sibling to <gameList>, which is invalid multi-root XML that the incremental parser rejects, so those files fall back to the previous strip-then-parse path. Entries are keyed by filename, so re-reading elements already consumed before the failure cannot corrupt the result. Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01TLTDjv3niosCXZWtjKELK2