From 4503f29d8a28c44edcce9c5d8ff6aab71302bde3 Mon Sep 17 00:00:00 2001 From: Alex Saveau Date: Fri, 26 Jul 2024 16:52:38 -0700 Subject: [PATCH] Avoid streaming through the haystack an extra time in case-insensitive search Signed-off-by: Alex Saveau --- client-sdk/src/search.rs | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/client-sdk/src/search.rs b/client-sdk/src/search.rs index 924758a..4f76442 100644 --- a/client-sdk/src/search.rs +++ b/client-sdk/src/search.rs @@ -62,8 +62,8 @@ struct PlainIgnoreCaseQuery { impl QueryImpl for PlainIgnoreCaseQuery { fn find(&mut self, haystack: &[u8]) -> Option<(usize, usize)> { self.cache.clear(); - self.cache.extend_from_slice(haystack); - self.cache.make_ascii_lowercase(); + self.cache + .extend(haystack.iter().map(u8::to_ascii_lowercase)); self.inner.find(&self.cache) }