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

Side by Side Diff: lib/filterStorage.js

Issue 29550598: Issue 5735 - Use JS Map instead of Object for Filter.knownFilters (Closed) Base URL: https://github.com/adblockplus/adblockpluscore.git
Patch Set: Created Sept. 20, 2017, 8:20 a.m.
Left:
Right:
Use n/p to move between diff chunks; N/P to move between comments.
Jump to:
View unified diff | Download patch
« lib/filterClasses.js ('K') | « lib/filterClasses.js ('k') | no next file » | 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 319 matching lines...) Expand 10 before | Expand all | Expand 10 after
330 }, 330 },
331 331
332 /** 332 /**
333 * Resets hit count for some filters 333 * Resets hit count for some filters
334 * @param {Filter[]} filters filters to be reset, if null all filters will 334 * @param {Filter[]} filters filters to be reset, if null all filters will
335 * be reset 335 * be reset
336 */ 336 */
337 resetHitCounts(filters) 337 resetHitCounts(filters)
338 { 338 {
339 if (!filters) 339 if (!filters)
340 { 340 {
Wladimir Palant 2017/09/20 08:59:10 Nit: You can remove the brackets around this block
sergei 2017/09/20 09:22:40 Done.
341 filters = []; 341 filters = Filter.knownFilters.values();
342 for (let text in Filter.knownFilters)
343 filters.push(Filter.knownFilters[text]);
344 } 342 }
345 for (let filter of filters) 343 for (let filter of filters)
346 { 344 {
347 filter.hitCount = 0; 345 filter.hitCount = 0;
348 filter.lastHit = 0; 346 filter.lastHit = 0;
349 } 347 }
350 }, 348 },
351 349
352 /** 350 /**
353 * @callback TextSink 351 * @callback TextSink
(...skipping 334 matching lines...) Expand 10 before | Expand all | Expand 10 after
688 } 686 }
689 687
690 /** 688 /**
691 * Listener returned by FilterStorage.importData(), parses filter data. 689 * Listener returned by FilterStorage.importData(), parses filter data.
692 * @constructor 690 * @constructor
693 */ 691 */
694 function INIParser() 692 function INIParser()
695 { 693 {
696 this.fileProperties = this.curObj = {}; 694 this.fileProperties = this.curObj = {};
697 this.subscriptions = []; 695 this.subscriptions = [];
698 this.knownFilters = Object.create(null); 696 this.knownFilters = new Map();
699 this.knownSubscriptions = Object.create(null); 697 this.knownSubscriptions = Object.create(null);
700 } 698 }
701 INIParser.prototype = 699 INIParser.prototype =
702 { 700 {
703 linesProcessed: 0, 701 linesProcessed: 0,
704 subscriptions: null, 702 subscriptions: null,
705 knownFilters: null, 703 knownFilters: null,
706 knownSubscriptions: null, 704 knownSubscriptions: null,
707 wantObj: true, 705 wantObj: true,
708 fileProperties: null, 706 fileProperties: null,
(...skipping 68 matching lines...) Expand 10 before | Expand all | Expand 10 after
777 else if (this.wantObj === false && val) 775 else if (this.wantObj === false && val)
778 this.curObj.push(val.replace(/\\\[/g, "[")); 776 this.curObj.push(val.replace(/\\\[/g, "["));
779 } 777 }
780 finally 778 finally
781 { 779 {
782 Filter.knownFilters = origKnownFilters; 780 Filter.knownFilters = origKnownFilters;
783 Subscription.knownSubscriptions = origKnownSubscriptions; 781 Subscription.knownSubscriptions = origKnownSubscriptions;
784 } 782 }
785 } 783 }
786 }; 784 };
OLDNEW
« lib/filterClasses.js ('K') | « lib/filterClasses.js ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld