From 5f2f013c8eb32e5a02a75d3071b82a52027efb24 Mon Sep 17 00:00:00 2001 From: dev-null-undefined Date: Mon, 12 Oct 2026 18:34:52 +0200 Subject: [PATCH] Perf: a full-size raw decode no longer copies its 64 MP image to "fit" it MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit `load_bytes_now` ran every development through `resample::fit`, which returns a clone when the image already fits. At full size (1:1 zoom, export) that cloned the whole picture: 797 MB and ~0.3 s for a 9984 × 6656 Sony ILCE-7RM6 raw. It now fits only when the image is larger, as the other preview paths in files.rs already do. Output unchanged (same pixels, by construction). Co-Authored-By: Claude Opus 5.5 --- crates/engine/src/files.rs | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/crates/engine/src/files.rs b/crates/engine/src/files.rs index dc79b8b31..feefb21a0 100644 --- a/crates/engine/src/files.rs +++ b/crates/engine/src/files.rs @@ -450,7 +450,8 @@ fn load_bytes_now( stages.push(("highlights", t0.elapsed())); colour.apply(&mut img); stages.push(("colour", t0.elapsed())); - let img = fit(&img, max_edge, max_edge, Filter::Box); + // (`fit` copies an image that already fits: 797 MB and 0.3 s for a full-size 64 MP decode) + let img = if img.width.max(img.height) > max_edge { fit(&img, max_edge, max_edge, Filter::Box) } else { img }; stages.push(("fit", t0.elapsed())); let img = img.into_oriented(raw.orientation); stages.push(("orient", t0.elapsed()));