forked from 1b-agent/opencadstudio-upstream
view_window() rebuilt the 256-bucket ACI layer-usage table inline on every modal view: unconditional 256-Vec allocation plus sort_by_key (lowercase key recomputed per comparison). Extract pure build_layer_usage(), build it only when the CTB path needs it (STB path now allocates nothing), and sort with sort_by_cached_key while skipping trivial buckets. Tests: - build_layer_usage_buckets_index_colors: ACI bucketing + case-insensitive order - build_layer_usage_ignores_non_index_colors: truecolor layers excluded Bench (cargo bench ui_plotstyle_layer_usage, 200 layers): ~13us median, PASS. A/B vs pre-change inline code: ~15.7us -> ~12-13us (~22% faster).