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

Side by Side Diff: lib/matcher.js

Issue 30011555: Issue 7303 - Deprecate the use of String.prototype.substr() (Closed) Base URL: https://hg.adblockplus.org/adblockpluscore/
Patch Set: Created Feb. 19, 2019, 4:47 p.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 | « lib/filterClasses.js ('k') | lib/rsa.js » ('j') | 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 386 matching lines...) Expand 10 before | Expand all | Expand 10 after
397 return result; 397 return result;
398 398
399 let candidates = pattern.toLowerCase().match(allKeywordsRegExp); 399 let candidates = pattern.toLowerCase().match(allKeywordsRegExp);
400 if (!candidates) 400 if (!candidates)
401 return result; 401 return result;
402 402
403 let resultCount = 0xFFFFFF; 403 let resultCount = 0xFFFFFF;
404 let resultLength = 0; 404 let resultLength = 0;
405 for (let i = 0, l = candidates.length; i < l; i++) 405 for (let i = 0, l = candidates.length; i < l; i++)
406 { 406 {
407 let candidate = candidates[i].substr(1); 407 let candidate = candidates[i].substring(1);
408 let simpleFilters = this._simpleFiltersByKeyword.get(candidate); 408 let simpleFilters = this._simpleFiltersByKeyword.get(candidate);
409 let complexFilters = this._complexFiltersByKeyword.get(candidate); 409 let complexFilters = this._complexFiltersByKeyword.get(candidate);
410 let count = (typeof simpleFilters != "undefined" ? 410 let count = (typeof simpleFilters != "undefined" ?
411 simpleFilters.size : 0) + 411 simpleFilters.size : 0) +
412 (typeof complexFilters != "undefined" ? 412 (typeof complexFilters != "undefined" ?
413 complexFilters.size : 0); 413 complexFilters.size : 0);
414 if (count < resultCount || 414 if (count < resultCount ||
415 (count == resultCount && candidate.length > resultLength)) 415 (count == resultCount && candidate.length > resultLength))
416 { 416 {
417 result = candidate; 417 result = candidate;
(...skipping 457 matching lines...) Expand 10 before | Expand all | Expand 10 after
875 875
876 exports.CombinedMatcher = CombinedMatcher; 876 exports.CombinedMatcher = CombinedMatcher;
877 877
878 /** 878 /**
879 * Shared {@link CombinedMatcher} instance that should usually be used. 879 * Shared {@link CombinedMatcher} instance that should usually be used.
880 * @type {CombinedMatcher} 880 * @type {CombinedMatcher}
881 */ 881 */
882 let defaultMatcher = new CombinedMatcher(); 882 let defaultMatcher = new CombinedMatcher();
883 883
884 exports.defaultMatcher = defaultMatcher; 884 exports.defaultMatcher = defaultMatcher;
OLDNEW
« no previous file with comments | « lib/filterClasses.js ('k') | lib/rsa.js » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld