From 7b0d58ab7cf85fd1780599ea688095fbab8651f7 Mon Sep 17 00:00:00 2001 From: Kornel Date: Mon, 2 Oct 2023 12:30:30 +0100 Subject: [PATCH] Eliminate extra length checks from diff() loop --- src/encoder.rs | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/src/encoder.rs b/src/encoder.rs index 993fcdcd4e..ef63894320 100644 --- a/src/encoder.rs +++ b/src/encoder.rs @@ -1359,7 +1359,14 @@ fn diff( ) { debug_assert!(dst.len() % src1.rect().width == 0); let width = src1.rect().width; - if width == 0 || width != src2.rect().width { + let height = src1.rect().height; + + if width == 0 + || width != src2.rect().width + || height == 0 + || src1.rows_iter().len() != src2.rows_iter().len() + { + debug_assert!(false); return; }