| OLD | NEW |
| 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 Loading... |
| 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 Loading... |
| 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; |
| OLD | NEW |