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

Unified Diff: lib/matcher.js

Issue 29993555: Issue 7245 - Move protocol keyword to end of candidate list (Closed) Base URL: https://hg.adblockplus.org/adblockpluscore/
Patch Set: Minor improvement Created Jan. 30, 2019, 5:39 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
@@ -506,16 +506,24 @@
* @private
*/
_matchesAnyInternal(location, typeMask, docDomain, thirdParty, sitekey,
specificOnly)
{
let candidates = location.toLowerCase().match(/[a-z0-9%]{3,}/g);
if (candidates === null)
candidates = [];
+
+ // The first keyword in a URL is the protocol (usually "https" or "http").
+ // This is an outlier: it has hundreds of filters typically, yet it rarely
+ // ever has a match. We cut down the amount of processing for blocked URLs
+ // significantly by moving it to the end of the list.
+ if (candidates.length > 1)
+ candidates.push(candidates.shift());
+
candidates.push("");
let whitelistHit = null;
let blacklistHit = null;
// If the type mask includes no types other than whitelist-only types, we
// can skip the blacklist.
if ((typeMask & ~WHITELIST_ONLY_TYPES) != 0)
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld