Bug 594223 - Don't call searchFunction unnecessarily in MatchAutoCompleteFunction::OnFunctionCall. r,a=sdwilsh

This commit is contained in:
Justin Lebar 2010-11-18 16:09:30 -08:00
parent 37f895fef1
commit 89c81d0188

View File

@ -395,21 +395,21 @@ namespace places {
while (matches && tokenizer.hasMoreTokens()) {
const nsDependentCSubstring &token = tokenizer.nextToken();
bool matchTags = searchFunction(token, tags);
bool matchTitle = searchFunction(token, title);
// Make sure we match something in the title or tags if we have to.
matches = matchTags || matchTitle;
if (HAS_BEHAVIOR(TITLE) && !matches)
break;
bool matchURL = searchFunction(token, fixedURI);
// If we do not match the URL when we have to, reset matches to false.
// Otherwise, keep track that we did match the current search.
if (HAS_BEHAVIOR(URL) && !matchURL)
matches = false;
else
matches = matches || matchURL;
if (HAS_BEHAVIOR(TITLE) && HAS_BEHAVIOR(URL)) {
matches = (searchFunction(token, title) || searchFunction(token, tags)) &&
searchFunction(token, fixedURI);
}
else if (HAS_BEHAVIOR(TITLE)) {
matches = searchFunction(token, title) || searchFunction(token, tags);
}
else if (HAS_BEHAVIOR(URL)) {
matches = searchFunction(token, fixedURI);
}
else {
matches = searchFunction(token, title) ||
searchFunction(token, tags) ||
searchFunction(token, fixedURI);
}
}
NS_ADDREF(*_result = new IntegerVariant(matches ? 1 : 0));