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:
@@ -179,7 +179,7 @@ public:
|
|||||||
// Every search term must be found in one of the package texts
|
// Every search term must be found in one of the package texts
|
||||||
for (int32 i = fSearchTerms.CountStrings() - 1; i >= 0; i--) {
|
for (int32 i = fSearchTerms.CountStrings() - 1; i >= 0; i--) {
|
||||||
const BString& term = fSearchTerms.StringAt(i);
|
const BString& term = fSearchTerms.StringAt(i);
|
||||||
if (!_TextContains(package->Name(), term)
|
if (package->Name().FindFirst(term) < 0
|
||||||
&& !_AcceptsPackageFromPublisher(package, term)
|
&& !_AcceptsPackageFromPublisher(package, term)
|
||||||
&& !_AcceptsPackageFromLocalizedText(package, term)) {
|
&& !_AcceptsPackageFromLocalizedText(package, term)) {
|
||||||
return false;
|
return false;
|
||||||
@@ -205,8 +205,7 @@ public:
|
|||||||
private:
|
private:
|
||||||
bool _TextContains(BString text, const BString& string) const
|
bool _TextContains(BString text, const BString& string) const
|
||||||
{
|
{
|
||||||
text.ToLower();
|
int32 index = text.IFindFirst(string);
|
||||||
int32 index = text.FindFirst(string);
|
|
||||||
return index >= 0;
|
return index >= 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user