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

Delta Between Two Patch Sets: lib/matcher.js

Issue 29993555: Issue 7245 - Move protocol keyword to end of candidate list (Closed) Base URL: https://hg.adblockplus.org/adblockpluscore/
Left Patch Set: Created Jan. 30, 2019, 5:15 a.m.
Right 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:
Left: Side by side diff | Download
Right: Side by side diff | Download
« no previous file with change/comment | « no previous file | no next file » | no next file with change/comment »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
LEFTRIGHT
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 498 matching lines...) Expand 10 before | Expand all | Expand 10 after
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 514
515 // The first keyword in a URL is the protocol (usually "https" or "http"). 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 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 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. 518 // significantly by moving it to the end of the list.
519 if (candidates.length > 0) 519 if (candidates.length > 1)
520 candidates.push(candidates.shift()); 520 candidates.push(candidates.shift());
521 521
522 candidates.push(""); 522 candidates.push("");
523 523
524 let whitelistHit = null; 524 let whitelistHit = null;
525 let blacklistHit = null; 525 let blacklistHit = null;
526 526
527 // 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
528 // can skip the blacklist. 528 // can skip the blacklist.
529 if ((typeMask & ~WHITELIST_ONLY_TYPES) != 0) 529 if ((typeMask & ~WHITELIST_ONLY_TYPES) != 0)
(...skipping 152 matching lines...) Expand 10 before | Expand all | Expand 10 after
682 682
683 exports.CombinedMatcher = CombinedMatcher; 683 exports.CombinedMatcher = CombinedMatcher;
684 684
685 /** 685 /**
686 * Shared {@link CombinedMatcher} instance that should usually be used. 686 * Shared {@link CombinedMatcher} instance that should usually be used.
687 * @type {CombinedMatcher} 687 * @type {CombinedMatcher}
688 */ 688 */
689 let defaultMatcher = new CombinedMatcher(); 689 let defaultMatcher = new CombinedMatcher();
690 690
691 exports.defaultMatcher = defaultMatcher; 691 exports.defaultMatcher = defaultMatcher;
LEFTRIGHT
« no previous file | no next file » | Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Toggle Comments ('s')

Powered by Google App Engine
This is Rietveld