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

Delta Between Two Patch Sets: lib/filterClasses.js

Issue 29909576: [experiment] Issue 7045 - Optimize V8 memory layout of filter text Base URL: https://hg.adblockplus.org/adblockpluscore/
Left Patch Set: Created Oct. 15, 2018, 5:04 a.m.
Right Patch Set: Make domains parameter nullable and optional Created Oct. 15, 2018, 9:28 p.m.
Left:
Right:
Use n/p to move between diff chunks; N/P to move between comments.
Jump to:
Left: Side by side diff | Download
Right: Side by side diff | Download
« no previous file with change/comment | « no previous file | lib/filterText.js » ('j') | no next file with change/comment »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
LEFTRIGHT
1 /* 1 /*
2 * This file is part of Adblock Plus <https://adblockplus.org/>, 2 * This file is part of Adblock Plus <https://adblockplus.org/>,
3 * Copyright (C) 2006-present eyeo GmbH 3 * Copyright (C) 2006-present eyeo GmbH
4 * 4 *
5 * Adblock Plus is free software: you can redistribute it and/or modify 5 * Adblock Plus is free software: you can redistribute it and/or modify
6 * it under the terms of the GNU General Public License version 3 as 6 * it under the terms of the GNU General Public License version 3 as
7 * published by the Free Software Foundation. 7 * published by the Free Software Foundation.
8 * 8 *
9 * Adblock Plus is distributed in the hope that it will be useful, 9 * Adblock Plus is distributed in the hope that it will be useful,
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of 10 * but WITHOUT ANY WARRANTY; without even the implied warranty of
(...skipping 879 matching lines...) Expand 10 before | Expand all | Expand 10 after
890 if (rewrite != null) 890 if (rewrite != null)
891 { 891 {
892 if (contentType == null) 892 if (contentType == null)
893 ({contentType} = RegExpFilter.prototype); 893 ({contentType} = RegExpFilter.prototype);
894 contentType &= ~(RegExpFilter.typeMap.SCRIPT | 894 contentType &= ~(RegExpFilter.typeMap.SCRIPT |
895 RegExpFilter.typeMap.SUBDOCUMENT | 895 RegExpFilter.typeMap.SUBDOCUMENT |
896 RegExpFilter.typeMap.OBJECT | 896 RegExpFilter.typeMap.OBJECT |
897 RegExpFilter.typeMap.OBJECT_SUBREQUEST); 897 RegExpFilter.typeMap.OBJECT_SUBREQUEST);
898 } 898 }
899 899
900 if (domains) 900 [origText, text, domains, sitekeys, csp, rewrite] =
901 { 901 optimizeRegExpFilterText(origText, text, domains, sitekeys, csp, rewrite);
902 [origText, text, domains, sitekeys, csp, rewrite] =
903 optimizeRegExpFilterText(origText, text, domains, sitekeys, csp, rewrite);
904 }
905 902
906 try 903 try
907 { 904 {
908 if (blocking) 905 if (blocking)
909 { 906 {
910 if (csp && Filter.invalidCSPRegExp.test(csp)) 907 if (csp && Filter.invalidCSPRegExp.test(csp))
911 return new InvalidFilter(origText, "filter_invalid_csp"); 908 return new InvalidFilter(origText, "filter_invalid_csp");
912 909
913 return new BlockingFilter(origText, text, contentType, matchCase, domains, 910 return new BlockingFilter(origText, text, contentType, matchCase, domains,
914 thirdParty, sitekeys, collapse, csp, rewrite); 911 thirdParty, sitekeys, collapse, csp, rewrite);
(...skipping 199 matching lines...) Expand 10 before | Expand all | Expand 10 after
1114 * ElemHideEmulationFilter|SnippetFilter|InvalidFilter} 1111 * ElemHideEmulationFilter|SnippetFilter|InvalidFilter}
1115 */ 1112 */
1116 ContentFilter.fromText = function(text, domains, type, body) 1113 ContentFilter.fromText = function(text, domains, type, body)
1117 { 1114 {
1118 // We don't allow content filters which have any empty domains. 1115 // We don't allow content filters which have any empty domains.
1119 // Note: The ContentFilter.prototype.domainSeparator is duplicated here, if 1116 // Note: The ContentFilter.prototype.domainSeparator is duplicated here, if
1120 // that changes this must be changed too. 1117 // that changes this must be changed too.
1121 if (domains && /(^|,)~?(,|$)/.test(domains)) 1118 if (domains && /(^|,)~?(,|$)/.test(domains))
1122 return new InvalidFilter(text, "filter_invalid_domain"); 1119 return new InvalidFilter(text, "filter_invalid_domain");
1123 1120
1124 if (domains) 1121 [text, domains, type, body] =
1125 { 1122 optimizeContentFilterText(text, domains, type, body);
1126 [text, domains, type, body] =
1127 optimizeContentFilterText(text, domains, type, body);
1128 }
1129 1123
1130 if (type == "@") 1124 if (type == "@")
1131 return new ElemHideException(text, domains, body); 1125 return new ElemHideException(text, domains, body);
1132 1126
1133 if (type == "?" || type == "$") 1127 if (type == "?" || type == "$")
1134 { 1128 {
1135 // Element hiding emulation and snippet filters are inefficient so we need 1129 // Element hiding emulation and snippet filters are inefficient so we need
1136 // to make sure that they're only applied if they specify active domains 1130 // to make sure that they're only applied if they specify active domains
1137 if (!(/,[^~][^,.]*\.[^,]/.test("," + domains) || 1131 if (!(/,[^~][^,.]*\.[^,]/.test("," + domains) ||
1138 ("," + domains + ",").includes(",localhost,"))) 1132 ("," + domains + ",").includes(",localhost,")))
(...skipping 112 matching lines...) Expand 10 before | Expand all | Expand 10 after
1251 1245
1252 /** 1246 /**
1253 * Script that should be executed 1247 * Script that should be executed
1254 * @type {string} 1248 * @type {string}
1255 */ 1249 */
1256 get script() 1250 get script()
1257 { 1251 {
1258 return this.body; 1252 return this.body;
1259 } 1253 }
1260 }); 1254 });
LEFTRIGHT
« no previous file | lib/filterText.js » ('j') | Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Toggle Comments ('s')

Powered by Google App Engine
This is Rietveld