From fbb27923df5f668b9723bcd9720f5723673948f6 Mon Sep 17 00:00:00 2001 From: Augustin Cavalier Date: Sat, 15 Feb 2025 21:10:00 -0500 Subject: [PATCH] HaikuDepot: Use more optimal string operations in searching. * package->Name() is always lowercase, don't bother using lowercase operations on it. * Use IFindFirst rather than transforming the string; this uses strcasestr internally which operates per-character. Loosely based on a patch by oco in #19421. --- src/apps/haikudepot/packagemodel/PackageFilter.cpp | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/src/apps/haikudepot/packagemodel/PackageFilter.cpp b/src/apps/haikudepot/packagemodel/PackageFilter.cpp index b7706a1848..631ac33b53 100644 --- a/src/apps/haikudepot/packagemodel/PackageFilter.cpp +++ b/src/apps/haikudepot/packagemodel/PackageFilter.cpp @@ -179,7 +179,7 @@ public: // Every search term must be found in one of the package texts for (int32 i = fSearchTerms.CountStrings() - 1; i >= 0; i--) { const BString& term = fSearchTerms.StringAt(i); - if (!_TextContains(package->Name(), term) + if (package->Name().FindFirst(term) < 0 && !_AcceptsPackageFromPublisher(package, term) && !_AcceptsPackageFromLocalizedText(package, term)) { return false; @@ -205,8 +205,7 @@ public: private: bool _TextContains(BString text, const BString& string) const { - text.ToLower(); - int32 index = text.FindFirst(string); + int32 index = text.IFindFirst(string); return index >= 0; }