mirror of
https://github.com/storytold/lightcraft.git
synced 2026-10-26 11:09:23 -06:00
A Lightroom collection imported whole (11 113 presets, a 42 MB presets.json) made every interaction take seconds: - Session::persist ran after every command and serialized the whole preset list to compare it with the last write: 609 ms per slider tick (release, the real collection). Session::presets is now a PresetList whose generation changes on mutable access; persist serializes only when it (or the profile lists) changed, and skips the write when the bytes hash the same. develop.set: 609 ms -> 2.3 ms; preset.apply: 598 ms -> 3.1 ms. - The Presets panel deep-cloned every preset into a BTreeMap, built a row, widget id and (with thumbnails) a variant render job for each of them every frame. Grouping is cached per generation and only rows in view are laid out: 5041 -> ~20 rows a frame, 2.3 ms with 5000 presets. - The preset pickers (Import dialog, Settings > Import) build only the rows in view. - add_presets and opening a library compared every preset with every other (quadratic); both use hash indexes now. Opening no longer serializes the list once just to remember it. Tests: develop commands don't re-serialize unchanged presets (and a change is still saved), generation semantics, a 20 000-preset import, and the panel building only visible rows (fails on the old code: 5041 rows). An ignored bench (presets_scale_bench, LIGHTCRAFT_BENCH_PRESETS) times a real presets.json. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>