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: address comments Created Sept. 20, 2017, 11:31 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 filters = Filter.knownFilters.values();
341 filters = [];
342 for (let text in Filter.knownFilters)
343 filters.push(Filter.knownFilters[text]);
344 }
345 for (let filter of filters) 341 for (let filter of filters)
346 { 342 {
347 filter.hitCount = 0; 343 filter.hitCount = 0;
348 filter.lastHit = 0; 344 filter.lastHit = 0;
349 } 345 }
350 }, 346 },
351 347
352 /** 348 /**
353 * @callback TextSink 349 * @callback TextSink
354 * @param {string?} line 350 * @param {string?} line
(...skipping 333 matching lines...) Expand 10 before | Expand all | Expand 10 after
688 } 684 }
689 685
690 /** 686 /**
691 * Listener returned by FilterStorage.importData(), parses filter data. 687 * Listener returned by FilterStorage.importData(), parses filter data.
692 * @constructor 688 * @constructor
693 */ 689 */
694 function INIParser() 690 function INIParser()
695 { 691 {
696 this.fileProperties = this.curObj = {}; 692 this.fileProperties = this.curObj = {};
697 this.subscriptions = []; 693 this.subscriptions = [];
698 this.knownFilters = Object.create(null); 694 this.knownFilters = new Map();
699 this.knownSubscriptions = Object.create(null); 695 this.knownSubscriptions = Object.create(null);
700 } 696 }
701 INIParser.prototype = 697 INIParser.prototype =
702 { 698 {
703 linesProcessed: 0, 699 linesProcessed: 0,
704 subscriptions: null, 700 subscriptions: null,
705 knownFilters: null, 701 knownFilters: null,
706 knownSubscriptions: null, 702 knownSubscriptions: null,
707 wantObj: true, 703 wantObj: true,
708 fileProperties: null, 704 fileProperties: null,
(...skipping 68 matching lines...) Expand 10 before | Expand all | Expand 10 after
777 else if (this.wantObj === false && val) 773 else if (this.wantObj === false && val)
778 this.curObj.push(val.replace(/\\\[/g, "[")); 774 this.curObj.push(val.replace(/\\\[/g, "["));
779 } 775 }
780 finally 776 finally
781 { 777 {
782 Filter.knownFilters = origKnownFilters; 778 Filter.knownFilters = origKnownFilters;
783 Subscription.knownSubscriptions = origKnownSubscriptions; 779 Subscription.knownSubscriptions = origKnownSubscriptions;
784 } 780 }
785 } 781 }
786 }; 782 };
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