From 7697163c59604148226268917ad0eb277b7a316b Mon Sep 17 00:00:00 2001 From: Dmitry Marakasov Date: Thu, 25 Jan 2024 23:40:47 +0300 Subject: [PATCH] String comparison optimization --- src/string.rs | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/src/string.rs b/src/string.rs index 6f11bcc..87cfba2 100644 --- a/src/string.rs +++ b/src/string.rs @@ -22,6 +22,10 @@ pub fn strings_are_equal_ci(a: &str, b: &str) -> bool { let mut a_it = a.bytes(); let mut b_it = b.bytes(); + if a.len() != b.len() { + return false; + } + loop { match (a_it.next(), b_it.next()) { (Some(a_val), Some(b_val)) => {