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

Unified Diff: lib/filterClasses.js

Issue 5150730151264256: Issue 354 - Avoid a string copy that is unnecessary most of the time (Closed)
Patch Set: Created April 4, 2014, 3:07 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
@@ -307,17 +307,17 @@ ActiveFilter.prototype =
* @type Object
*/
get domains()
{
let domains = null;
if (this.domainSource)
{
- let list = this.domainSource.split(this.domainSeparator);
+ let list = this.domainSource.toUpperCase().split(this.domainSeparator);
Wladimir Palant 2014/04/08 12:10:05 I see, I didn't realize what this was doing. The
if (list.length == 1 && list[0][0] != "~")
{
// Fast track for the common one-domain scenario
domains = {__proto__: null, "": false};
if (this.ignoreTrailingDot)
list[0] = list[0].replace(/\.+$/, "");
domains[list[0]] = true;
}
@@ -347,17 +347,17 @@ ActiveFilter.prototype =
if (!domains)
domains = {__proto__: null};
domains[domain] = include;
}
domains[""] = !hasIncludes;
}
- delete this.domainSource;
+ this.domainSource = null;
}
this.__defineGetter__("domains", function() domains);
return this.domains;
},
/**
* Checks whether this filter is active on a domain.
@@ -740,17 +740,17 @@ WhitelistFilter.prototype =
* @param {String} text see Filter()
* @param {String} domains (optional) Host names or domains the filter should be restricted to
* @param {String} selector CSS selector for the HTML elements that should be hidden
* @constructor
* @augments ActiveFilter
*/
function ElemHideBase(text, domains, selector)
{
- ActiveFilter.call(this, text, domains ? domains.toUpperCase() : null);
+ ActiveFilter.call(this, text, domains || null);
if (domains)
this.selectorDomain = domains.replace(/,~[^,]+/g, "").replace(/^~[^,]+,?/, "").toLowerCase();
this.selector = selector;
}
exports.ElemHideBase = ElemHideBase;
ElemHideBase.prototype =
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld