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

Unified Diff: lib/filterClasses.js

Issue 29816555: Issue 6727 - Avoid getter for multi-domain cases (Closed) Base URL: https://hg.adblockplus.org/adblockpluscore/
Patch Set: Created June 26, 2018, 5:02 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 | « no previous file | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: lib/filterClasses.js
===================================================================
--- a/lib/filterClasses.js
+++ b/lib/filterClasses.js
@@ -395,39 +395,31 @@
/**
* Map containing domains that this filter should match on/not match
* on or null if the filter should match on all domains
* @type {?Map.<string,boolean>}
*/
get domains()
{
- let prop = Object.getOwnPropertyDescriptor(this, "_domains");
- if (prop)
- {
- let {value} = prop;
- return typeof value == "string" ?
- new Map([[value, true], ["", false]]) : value;
- }
-
let domains = null;
if (this.domainSource)
{
let source = this.domainSource;
if (!this.domainSourceIsLowerCase)
{
// RegExpFilter already have lowercase domains
source = source.toLowerCase();
}
let list = source.split(this.domainSeparator);
if (list.length == 1 && list[0][0] != "~")
{
// Fast track for the common one-domain scenario
- domains = list[0];
+ Object.defineProperty(this, "_singleDomain", {value: list[0]});
}
else
{
let hasIncludes = false;
for (let i = 0; i < list.length; i++)
{
let domain = list[i];
if (domain == "")
@@ -441,29 +433,35 @@
}
else
{
include = true;
hasIncludes = true;
}
if (!domains)
+ {
domains = new Map();
+ Object.defineProperty(this, "domains", {value: domains});
+ }
domains.set(domain, include);
}
if (domains)
domains.set("", !hasIncludes);
}
this.domainSource = null;
}
- Object.defineProperty(this, "_domains", {value: domains});
- return this.domains;
+ let singleDomain = this._singleDomain;
+ if (singleDomain)
+ return new Map([[singleDomain, true], ["", false]]);
+
+ return domains;
},
/**
* Array containing public keys of websites that this filter should apply to
* @type {?string[]}
*/
sitekeys: null,
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld