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

Delta Between Two Patch Sets: lib/elemHide.js

Issue 29743730: Issue 6559 - Use maps and sets where appropriate (Closed) Base URL: https://hg.adblockplus.org/adblockpluscore/
Left Patch Set: Update comments Created April 6, 2018, 12:40 p.m.
Right Patch Set: Revert logic in getUnconditionalFilterKeys Created April 6, 2018, 1:32 p.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 | « lib/downloader.js ('k') | lib/elemHideEmulation.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
11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 * GNU General Public License for more details. 12 * GNU General Public License for more details.
13 * 13 *
14 * You should have received a copy of the GNU General Public License 14 * You should have received a copy of the GNU General Public License
15 * along with Adblock Plus. If not, see <http://www.gnu.org/licenses/>. 15 * along with Adblock Plus. If not, see <http://www.gnu.org/licenses/>.
16 */ 16 */
17 17
18 "use strict"; 18 "use strict";
19 19
20 /** 20 /**
21 * @fileOverview Element hiding implementation. 21 * @fileOverview Element hiding implementation.
22 */ 22 */
23 23
24 const {ElemHideException} = require("./filterClasses"); 24 const {ElemHideException} = require("./filterClasses");
25 const {FilterNotifier} = require("./filterNotifier"); 25 const {FilterNotifier} = require("./filterNotifier");
26 26
27 /** 27 /**
28 * Lookup table, filters by their associated key 28 * Lookup table, filters by their associated key
29 * @type {Filter[]} 29 * @type {Filter[]}
Manish Jethani 2018/04/06 12:44:09 I've updated some of the types here.
30 */ 30 */
31 let filterByKey = []; 31 let filterByKey = [];
32 32
33 /** 33 /**
34 * Lookup table, keys of the filters by filter 34 * Lookup table, keys of the filters by filter
35 * @type {Map.<Filter,number>} 35 * @type {Map.<Filter,number>}
Manish Jethani 2018/04/06 12:44:09 The key is in fact a number.
36 */ 36 */
37 let keyByFilter = new Map(); 37 let keyByFilter = new Map();
38 38
39 /** 39 /**
40 * Nested lookup table, filter (or false if inactive) by filter key by domain. 40 * Nested lookup table, filter (or false if inactive) by filter key by domain.
41 * (Only contains filters that aren't unconditionally matched for all domains.) 41 * (Only contains filters that aren't unconditionally matched for all domains.)
42 * @type {Map.<string,Map.<number,(Filter|boolean)>>} 42 * @type {Map.<string,Map.<number,(Filter|boolean)>>}
43 */ 43 */
44 let filtersByDomain = new Map(); 44 let filtersByDomain = new Map();
45 45
(...skipping 243 matching lines...) Expand 10 before | Expand all | Expand 10 after
289 }, 289 },
290 290
291 /** 291 /**
292 * Returns a list of filter keys for selectors which apply to all websites 292 * Returns a list of filter keys for selectors which apply to all websites
293 * without exception. 293 * without exception.
294 * @returns {number[]} 294 * @returns {number[]}
295 */ 295 */
296 getUnconditionalFilterKeys() 296 getUnconditionalFilterKeys()
297 { 297 {
298 if (!unconditionalFilterKeys) 298 if (!unconditionalFilterKeys)
299 unconditionalFilterKeys = [...filterKeyBySelector.values()]; 299 {
300 let selectors = this.getUnconditionalSelectors();
301 unconditionalFilterKeys = [];
302 for (let selector of selectors)
303 unconditionalFilterKeys.push(filterKeyBySelector.get(selector));
304 }
300 return unconditionalFilterKeys.slice(); 305 return unconditionalFilterKeys.slice();
301 }, 306 },
302 307
303 308
304 /** 309 /**
305 * Constant used by getSelectorsForDomain to return all selectors applying to 310 * Constant used by getSelectorsForDomain to return all selectors applying to
306 * a particular hostname. 311 * a particular hostname.
307 */ 312 */
308 ALL_MATCHING: 0, 313 ALL_MATCHING: 0,
309 314
(...skipping 69 matching lines...) Expand 10 before | Expand all | Expand 10 after
379 384
380 let nextDot = currentDomain.indexOf("."); 385 let nextDot = currentDomain.indexOf(".");
381 currentDomain = nextDot == -1 ? "" : currentDomain.substr(nextDot + 1); 386 currentDomain = nextDot == -1 ? "" : currentDomain.substr(nextDot + 1);
382 } 387 }
383 388
384 if (provideFilterKeys) 389 if (provideFilterKeys)
385 return [selectors, filterKeys]; 390 return [selectors, filterKeys];
386 return selectors; 391 return selectors;
387 } 392 }
388 }; 393 };
LEFTRIGHT

Powered by Google App Engine
This is Rietveld