From e81c33da42fa416d74ad37f76039321965b1c5a6 Mon Sep 17 00:00:00 2001 From: Idan Horowitz Date: Mon, 4 Aug 2025 14:34:00 +0300 Subject: [PATCH] LibGfx: Skip manual cropping for the degenerate case --- Libraries/LibGfx/Bitmap.cpp | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/Libraries/LibGfx/Bitmap.cpp b/Libraries/LibGfx/Bitmap.cpp index d22cde2a2ba..5434ba8b1fe 100644 --- a/Libraries/LibGfx/Bitmap.cpp +++ b/Libraries/LibGfx/Bitmap.cpp @@ -160,6 +160,10 @@ void Bitmap::apply_mask(Gfx::Bitmap const& mask, MaskKind mask_kind) ErrorOr> Bitmap::cropped(Gfx::IntRect crop, Gfx::Color outside_color) const { + // OPTIMIZATION: Skip slow manual copying for NO-OP crops + if (crop == rect()) + return clone(); + auto new_bitmap = TRY(Gfx::Bitmap::create(format(), alpha_type(), { crop.width(), crop.height() })); for (int y = 0; y < crop.height(); ++y) {