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

Unified Diff: lib/filterClasses.js

Issue 29909576: [experiment] Issue 7045 - Optimize V8 memory layout of filter text Base URL: https://hg.adblockplus.org/adblockpluscore/
Patch Set: Created Oct. 15, 2018, 5: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 | lib/filterText.js » ('j') | 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
@@ -19,16 +19,18 @@
/**
* @fileOverview Definition of Filter class and its subclasses.
*/
const {filterNotifier} = require("./filterNotifier");
const {extend} = require("./coreUtils");
const {filterToRegExp} = require("./common");
+const {optimizeContentFilterText,
+ optimizeRegExpFilterText} = require("./filterText");
/**
* All known unique domain sources mapped to their parsed values.
* @type {Map.<string,Map.<string,boolean>>}
*/
let knownDomainMaps = new Map();
/**
@@ -890,16 +892,22 @@
if (contentType == null)
({contentType} = RegExpFilter.prototype);
contentType &= ~(RegExpFilter.typeMap.SCRIPT |
RegExpFilter.typeMap.SUBDOCUMENT |
RegExpFilter.typeMap.OBJECT |
RegExpFilter.typeMap.OBJECT_SUBREQUEST);
}
+ if (domains)
+ {
+ [origText, text, domains, sitekeys, csp, rewrite] =
+ optimizeRegExpFilterText(origText, text, domains, sitekeys, csp, rewrite);
+ }
+
try
{
if (blocking)
{
if (csp && Filter.invalidCSPRegExp.test(csp))
return new InvalidFilter(origText, "filter_invalid_csp");
return new BlockingFilter(origText, text, contentType, matchCase, domains,
@@ -1108,16 +1116,22 @@
ContentFilter.fromText = function(text, domains, type, body)
{
// We don't allow content filters which have any empty domains.
// Note: The ContentFilter.prototype.domainSeparator is duplicated here, if
// that changes this must be changed too.
if (domains && /(^|,)~?(,|$)/.test(domains))
return new InvalidFilter(text, "filter_invalid_domain");
+ if (domains)
+ {
+ [text, domains, type, body] =
+ optimizeContentFilterText(text, domains, type, body);
+ }
+
if (type == "@")
return new ElemHideException(text, domains, body);
if (type == "?" || type == "$")
{
// Element hiding emulation and snippet filters are inefficient so we need
// to make sure that they're only applied if they specify active domains
if (!(/,[^~][^,.]*\.[^,]/.test("," + domains) ||
« no previous file with comments | « no previous file | lib/filterText.js » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld