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

Unified Diff: lib/filterStorage.js

Issue 29802575: Issue 6559 - Replace fromObject with fromMap (Closed) Base URL: https://hg.adblockplus.org/adblockpluscore/
Patch Set: Created June 8, 2018, 1:59 p.m.
Use n/p to move between diff chunks; N/P to move between comments.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « lib/filterClasses.js ('k') | lib/subscriptionClasses.js » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: lib/filterStorage.js
===================================================================
--- a/lib/filterStorage.js
+++ b/lib/filterStorage.js
@@ -70,18 +70,19 @@
* Will be set to true if no patterns.ini file exists.
* @type {boolean}
*/
firstRun: false,
/**
* Map of properties listed in the filter storage file before the sections
* start. Right now this should be only the format version.
+ * @type {Map.<string,string>}
*/
- fileProperties: Object.create(null),
+ fileProperties: new Map(),
/**
* List of filter subscriptions containing all filters
* @type {Subscription[]}
*/
subscriptions: [],
/**
@@ -684,17 +685,17 @@
}
/**
* Listener returned by FilterStorage.importData(), parses filter data.
* @constructor
*/
function INIParser()
{
- this.fileProperties = this.curObj = {};
+ this.fileProperties = this.curObj = new Map();
this.subscriptions = [];
this.knownFilters = new Map();
this.knownSubscriptions = new Map();
}
INIParser.prototype =
{
linesProcessed: 0,
subscriptions: null,
@@ -710,30 +711,30 @@
let origKnownFilters = Filter.knownFilters;
Filter.knownFilters = this.knownFilters;
let origKnownSubscriptions = Subscription.knownSubscriptions;
Subscription.knownSubscriptions = this.knownSubscriptions;
let match;
try
{
if (this.wantObj === true && (match = /^(\w+)=(.*)$/.exec(val)))
- this.curObj[match[1]] = match[2];
+ this.curObj.set(match[1], match[2]);
else if (val === null || (match = /^\s*\[(.+)\]\s*$/.exec(val)))
{
if (this.curObj)
{
// Process current object before going to next section
switch (this.curSection)
{
case "filter":
- if ("text" in this.curObj)
- Filter.fromObject(this.curObj);
+ if (this.curObj.has("text"))
+ Filter.fromMap(this.curObj);
break;
case "subscription": {
- let subscription = Subscription.fromObject(this.curObj);
+ let subscription = Subscription.fromMap(this.curObj);
if (subscription)
this.subscriptions.push(subscription);
break;
}
case "subscription filters":
if (this.subscriptions.length)
{
let subscription = this.subscriptions[
@@ -754,17 +755,17 @@
return;
this.curSection = match[1].toLowerCase();
switch (this.curSection)
{
case "filter":
case "subscription":
this.wantObj = true;
- this.curObj = {};
+ this.curObj = new Map();
break;
case "subscription filters":
this.wantObj = false;
this.curObj = [];
break;
default:
this.wantObj = undefined;
this.curObj = null;
« no previous file with comments | « lib/filterClasses.js ('k') | lib/subscriptionClasses.js » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld