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

Side by Side 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.
Left:
Right:
Use n/p to move between diff chunks; N/P to move between comments.
Jump to:
View unified diff | Download patch
« no previous file with comments | « no previous file | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 /* 1 /*
2 * This file is part of Adblock Plus <https://adblockplus.org/>, 2 * This file is part of Adblock Plus <https://adblockplus.org/>,
3 * Copyright (C) 2006-present eyeo GmbH 3 * Copyright (C) 2006-present eyeo GmbH
4 * 4 *
5 * Adblock Plus is free software: you can redistribute it and/or modify 5 * Adblock Plus is free software: you can redistribute it and/or modify
6 * it under the terms of the GNU General Public License version 3 as 6 * it under the terms of the GNU General Public License version 3 as
7 * published by the Free Software Foundation. 7 * published by the Free Software Foundation.
8 * 8 *
9 * Adblock Plus is distributed in the hope that it will be useful, 9 * Adblock Plus is distributed in the hope that it will be useful,
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of 10 * but WITHOUT ANY WARRANTY; without even the implied warranty of
(...skipping 493 matching lines...) Expand 10 before | Expand all | Expand 10 after
504 * @see Matcher#matchesAny 504 * @see Matcher#matchesAny
505 * @inheritdoc 505 * @inheritdoc
506 * @private 506 * @private
507 */ 507 */
508 _matchesAnyInternal(location, typeMask, docDomain, thirdParty, sitekey, 508 _matchesAnyInternal(location, typeMask, docDomain, thirdParty, sitekey,
509 specificOnly) 509 specificOnly)
510 { 510 {
511 let candidates = location.toLowerCase().match(/[a-z0-9%]{3,}/g); 511 let candidates = location.toLowerCase().match(/[a-z0-9%]{3,}/g);
512 if (candidates === null) 512 if (candidates === null)
513 candidates = []; 513 candidates = [];
514
515 // The first keyword in a URL is the protocol (usually "https" or "http").
516 // This is an outlier: it has hundreds of filters typically, yet it rarely
517 // ever has a match. We cut down the amount of processing for blocked URLs
518 // significantly by moving it to the end of the list.
519 if (candidates.length > 1)
520 candidates.push(candidates.shift());
521
514 candidates.push(""); 522 candidates.push("");
515 523
516 let whitelistHit = null; 524 let whitelistHit = null;
517 let blacklistHit = null; 525 let blacklistHit = null;
518 526
519 // If the type mask includes no types other than whitelist-only types, we 527 // If the type mask includes no types other than whitelist-only types, we
520 // can skip the blacklist. 528 // can skip the blacklist.
521 if ((typeMask & ~WHITELIST_ONLY_TYPES) != 0) 529 if ((typeMask & ~WHITELIST_ONLY_TYPES) != 0)
522 { 530 {
523 for (let i = 0, l = candidates.length; !blacklistHit && i < l; i++) 531 for (let i = 0, l = candidates.length; !blacklistHit && i < l; i++)
(...skipping 150 matching lines...) Expand 10 before | Expand all | Expand 10 after
674 682
675 exports.CombinedMatcher = CombinedMatcher; 683 exports.CombinedMatcher = CombinedMatcher;
676 684
677 /** 685 /**
678 * Shared {@link CombinedMatcher} instance that should usually be used. 686 * Shared {@link CombinedMatcher} instance that should usually be used.
679 * @type {CombinedMatcher} 687 * @type {CombinedMatcher}
680 */ 688 */
681 let defaultMatcher = new CombinedMatcher(); 689 let defaultMatcher = new CombinedMatcher();
682 690
683 exports.defaultMatcher = defaultMatcher; 691 exports.defaultMatcher = defaultMatcher;
OLDNEW
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld