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

Unified Diff: lib/filterClasses.js

Issue 29876573: Issue 6937 - Lowercase RegExpFilter domains on demand (Closed) Base URL: https://hg.adblockplus.org/adblockpluscore/
Patch Set: Created Sept. 7, 2018, 3:04 a.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
@@ -442,39 +442,27 @@
/**
* Separator character used in domainSource property, must be
* overridden by subclasses
* @type {string}
*/
domainSeparator: null,
/**
- * Determines whether domainSource is already lower-case,
- * can be overridden by subclasses.
- * @type {boolean}
- */
- domainSourceIsLowerCase: false,
-
- /**
* 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 domains = null;
if (this.domainSource)
{
- let source = this.domainSource;
- if (!this.domainSourceIsLowerCase)
- {
- // RegExpFilter already have lowercase domains
- source = source.toLowerCase();
- }
+ let source = this.domainSource.toLowerCase();
Jon Sonesen 2018/09/07 03:09:33 Im super happy to see things like this go away heh
Manish Jethani 2018/09/07 03:42:44 I'm guessing "historical reasons." It may have bee
Jon Sonesen 2018/09/17 18:11:33 Yeah makes sense, thanks for explaining. I tested
Sebastian Noack 2018/09/17 19:20:59 This was an optimization at some point, but indeed
let knownMap = knownDomainMaps.get(source);
if (knownMap)
{
domains = knownMap;
}
else
{
@@ -685,21 +673,16 @@
// No need to convert this filter to regular expression yet, do it on demand
this.pattern = regexpSource;
}
}
exports.RegExpFilter = RegExpFilter;
RegExpFilter.prototype = extend(ActiveFilter, {
/**
- * @see ActiveFilter.domainSourceIsLowerCase
- */
- domainSourceIsLowerCase: true,
-
- /**
* Number of filters contained, will always be 1 (required to
* optimize {@link Matcher}).
* @type {number}
*/
length: 1,
/**
* The filter itself (required to optimize {@link Matcher}).
@@ -864,17 +847,17 @@
switch (option.toLowerCase())
{
case "match-case":
matchCase = !inverse;
break;
case "domain":
if (!value)
return new InvalidFilter(origText, "filter_unknown_option");
- domains = value.toLowerCase();
+ domains = value;
break;
case "third-party":
thirdParty = !inverse;
break;
case "collapse":
collapse = !inverse;
break;
case "sitekey":
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld