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

Delta Between Two Patch Sets: lib/elemHide.js

Issue 29773570: Issue 6652 - Implement fast selector lookups for unknown domains (Closed) Base URL: https://hg.adblockplus.org/adblockpluscore/
Left Patch Set: Strip out optimization for "generic-friendly" domains Created May 23, 2018, 12:02 a.m.
Right Patch Set: Avoid unnecessary Array.concat Created May 23, 2018, 12:22 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 | test/elemHide.js » ('j') | 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 122 matching lines...) Expand 10 before | Expand all | Expand 10 after
133 domain = nextDot == -1 ? null : domain.substring(nextDot + 1); 133 domain = nextDot == -1 ? null : domain.substring(nextDot + 1);
134 } 134 }
135 135
136 return filtersList; 136 return filtersList;
137 } 137 }
138 138
139 /** 139 /**
140 * Returns a list of selectors that apply on a domain from a given list of 140 * Returns a list of selectors that apply on a domain from a given list of
141 * filters 141 * filters
142 * @param {string} [domain] 142 * @param {string} [domain]
143 * @param {?Array.<?Map.<Filter,boolean>>} filtersList 143 * @param {Array.<?Map.<Filter,boolean>>} filtersList
144 * @param {Set.<Filter>} excludeSet 144 * @param {Set.<Filter>} excludeSet
145 * @returns {string[]} 145 * @returns {string[]}
146 */ 146 */
147 function matchSelectors(domain, filtersList, excludeSet) 147 function matchSelectors(domain, filtersList, excludeSet)
148 { 148 {
149 let matches = []; 149 let matches = [];
150 150
151 // This code is a performance hot-spot, which is why we've made certain 151 // This code is a performance hot-spot, which is why we've made certain
152 // micro-optimisations. Please be careful before making changes. 152 // micro-optimisations. Please be careful before making changes.
153 for (let i = 0; i < filtersList.length; i++) 153 for (let i = 0; i < filtersList.length; i++)
(...skipping 232 matching lines...) Expand 10 before | Expand all | Expand 10 after
386 getUnconditionalSelectors() 386 getUnconditionalSelectors()
387 .concat(getConditionalGenericSelectors()); 387 .concat(getConditionalGenericSelectors());
388 } 388 }
389 389
390 let excluded = new Set(); 390 let excluded = new Set();
391 let selectors = matchSelectors(domain, specificFilters, excluded); 391 let selectors = matchSelectors(domain, specificFilters, excluded);
392 392
393 if (specificOnly) 393 if (specificOnly)
394 return selectors; 394 return selectors;
395 395
396 let genericFilters = [filtersByDomain.get("")]; 396 return getUnconditionalSelectors()
397 selectors = selectors.concat(matchSelectors(domain, genericFilters, 397 .concat(selectors,
398 excluded)); 398 matchSelectors(domain, [filtersByDomain.get("")],
399 return getUnconditionalSelectors().concat(selectors); 399 excluded));
400 } 400 }
401 }; 401 };
LEFTRIGHT
« no previous file | test/elemHide.js » ('j') | Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Toggle Comments ('s')

Powered by Google App Engine
This is Rietveld