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

Delta Between Two Patch Sets: lib/elemHide.js

Issue 29342830: Issue 4057 - Further speedup ElemHide.getSelectorsforDomain (Closed)
Left Patch Set: Avoid extra dirty variable Created May 25, 2016, 7:59 a.m.
Right Patch Set: Addressed nits Created May 25, 2016, 10:50 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-2016 Eyeo GmbH 3 * Copyright (C) 2006-2016 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 43 matching lines...) Expand 10 before | Expand all | Expand 10 after
54 */ 54 */
55 var filtersByDomain = Object.create(null); 55 var filtersByDomain = Object.create(null);
56 56
57 /** 57 /**
58 * Lookup table, filters by selector. (Only contains filters that have a 58 * Lookup table, filters by selector. (Only contains filters that have a
59 * selector that is unconditionally matched for all domains.) 59 * selector that is unconditionally matched for all domains.)
60 */ 60 */
61 var filtersBySelector = Object.create(null); 61 var filtersBySelector = Object.create(null);
62 62
63 /** 63 /**
64 * Array of selectors which unconditionally apply to all domains, or null if 64 * This array caches the keys of filtersBySelector table (selectors which
65 * the array needs to be regenerated. 65 * unconditionally apply on all domains). It will be null if the cache needs to
Wladimir Palant 2016/05/25 10:43:03 Maybe change the description to better indicate wh
kzar 2016/05/25 10:51:28 Done.
66 */ 66 * be rebuilt.
67 var unconditionalSelectors = []; 67 */
Wladimir Palant 2016/05/25 10:43:03 Nit: Please initialize with null here and in clear
kzar 2016/05/25 10:51:28 Done.
68 var unconditionalSelectors = null;
68 69
69 /** 70 /**
70 * Object to be used instead when a filter has a blank domains property. 71 * Object to be used instead when a filter has a blank domains property.
71 */ 72 */
72 var defaultDomains = Object.create(null); 73 var defaultDomains = Object.create(null);
73 defaultDomains[""] = true; 74 defaultDomains[""] = true;
74 75
75 /** 76 /**
76 * Lookup table, keys are known element hiding exceptions 77 * Lookup table, keys are known element hiding exceptions
77 * @type Object 78 * @type Object
(...skipping 49 matching lines...) Expand 10 before | Expand all | Expand 10 after
127 128
128 /** 129 /**
129 * Removes all known filters 130 * Removes all known filters
130 */ 131 */
131 clear: function() 132 clear: function()
132 { 133 {
133 filterByKey = []; 134 filterByKey = [];
134 keyByFilter = Object.create(null); 135 keyByFilter = Object.create(null);
135 filtersByDomain = Object.create(null); 136 filtersByDomain = Object.create(null);
136 filtersBySelector = Object.create(null); 137 filtersBySelector = Object.create(null);
137 unconditionalSelectors = []; 138 unconditionalSelectors = null;
138 knownExceptions = Object.create(null); 139 knownExceptions = Object.create(null);
139 exceptions = Object.create(null); 140 exceptions = Object.create(null);
140 ElemHide.isDirty = false; 141 ElemHide.isDirty = false;
141 ElemHide.unapply(); 142 ElemHide.unapply();
142 }, 143 },
143 144
144 _addToFiltersByDomain: function(filter) 145 _addToFiltersByDomain: function(filter)
145 { 146 {
146 let key = keyByFilter[filter.text]; 147 let key = keyByFilter[filter.text];
147 let domains = filter.domains || defaultDomains; 148 let domains = filter.domains || defaultDomains;
(...skipping 377 matching lines...) Expand 10 before | Expand all | Expand 10 after
525 if (currentDomain == "") 526 if (currentDomain == "")
526 break; 527 break;
527 528
528 let nextDot = currentDomain.indexOf("."); 529 let nextDot = currentDomain.indexOf(".");
529 currentDomain = nextDot == -1 ? "" : currentDomain.substr(nextDot + 1); 530 currentDomain = nextDot == -1 ? "" : currentDomain.substr(nextDot + 1);
530 } 531 }
531 532
532 return selectors; 533 return selectors;
533 } 534 }
534 }; 535 };
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