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.
This commit is contained in:
Augustin Cavalier
2025-02-15 21:10:00 -05:00
parent ab36abde53
commit fbb27923df
@@ -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;
}