Rietveld Code Review Tool
Help | Bug tracker | Discussion group | Source code

Unified Diff: lib/matcher.js

Issue 29896562: Issue 7003 - Look up whitelist filter only if URL is blocked (Closed) Base URL: https://hg.adblockplus.org/adblockpluscore/
Patch Set: Created Sept. 30, 2018, 8:55 a.m.
Use n/p to move between diff chunks; N/P to move between comments.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « no previous file | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: lib/matcher.js
===================================================================
--- a/lib/matcher.js
+++ b/lib/matcher.js
@@ -362,34 +362,44 @@
matchesAnyInternal(location, typeMask, docDomain, thirdParty, sitekey,
specificOnly)
{
let candidates = location.toLowerCase().match(/[a-z0-9%]{3,}/g);
if (candidates === null)
candidates = [];
candidates.push("");
+ let whitelistHit = null;
let blacklistHit = null;
+
for (let i = 0, l = candidates.length; i < l; i++)
Sebastian Noack 2018/09/30 13:39:23 Any reason to not use for..of here?
Manish Jethani 2018/10/21 13:57:03 for..of is quite a bit slower in this case.
{
let substr = candidates[i];
- let result = this.whitelist._checkEntryMatch(
- substr, location, typeMask, docDomain, thirdParty, sitekey
+ blacklistHit = this.blacklist._checkEntryMatch(
+ substr, location, typeMask, docDomain, thirdParty, sitekey,
+ specificOnly
);
- if (result)
- return result;
- if (blacklistHit === null)
+ if (blacklistHit)
+ break;
+ }
+
+ if (blacklistHit)
+ {
+ for (let i = 0, l = candidates.length; i < l; i++)
{
- blacklistHit = this.blacklist._checkEntryMatch(
- substr, location, typeMask, docDomain, thirdParty, sitekey,
- specificOnly
+ let substr = candidates[i];
+ whitelistHit = this.whitelist._checkEntryMatch(
+ substr, location, typeMask, docDomain, thirdParty, sitekey
);
+ if (whitelistHit)
+ break;
}
}
- return blacklistHit;
+
+ return whitelistHit || blacklistHit;
}
/**
* @see Matcher#matchesAny
* @inheritdoc
*/
matchesAny(location, typeMask, docDomain, thirdParty, sitekey, specificOnly)
{
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld