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

Unified Diff: lib/filterClasses.js

Issue 29907586: Issue 6994 - Use shortcut matching for location only filters (Closed)
Patch Set: Reduce ternary use Created Oct. 21, 2018, 4:26 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 | lib/matcher.js » ('j') | lib/matcher.js » ('J')
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: lib/filterClasses.js
===================================================================
--- a/lib/filterClasses.js
+++ b/lib/filterClasses.js
@@ -767,16 +767,24 @@
this.sitekeySource = null;
}
Object.defineProperty(
this, "sitekeys", {value: sitekeys, enumerable: true}
);
return this.sitekeys;
},
+ /**
+ * Tests whether the filter only has location.
+ */
+ get isLocationOnly()
Manish Jethani 2018/10/21 16:06:52 Let's make this a function rather than a property.
Jon Sonesen 2018/10/23 17:36:32 Acknowledged.
+ {
+ return this.contentType == RegExpFilter.prototype.contentType &&
+ this.thirdParty == null && !this.domains && !this.sitekeys;
+ },
/**
* Tests whether the URL matches this filter
* @param {string} location URL to be tested
* @param {number} typeMask bitmask of content / request types to match
* @param {string} [docDomain] domain name of the document that loads the URL
* @param {boolean} [thirdParty] should be true if the URL is a third-party
* request
@@ -784,16 +792,20 @@
* @return {boolean} true in case of a match
*/
matches(location, typeMask, docDomain, thirdParty, sitekey)
{
return (this.contentType & typeMask) != 0 &&
(this.thirdParty == null || this.thirdParty == thirdParty) &&
this.isActiveOnDomain(docDomain, sitekey) &&
this.regexp.test(location);
+ },
+ matchesLocation(location)
+ {
+ return this.regexp.test(location);
}
});
/**
* Yields the filter itself (required to optimize {@link Matcher}).
* @yields {RegExpFilter}
*/
RegExpFilter.prototype[Symbol.iterator] = function*()
« no previous file with comments | « no previous file | lib/matcher.js » ('j') | lib/matcher.js » ('J')

Powered by Google App Engine
This is Rietveld