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

Delta Between Two Patch Sets: lib/filterClasses.js

Issue 29361640: Issue 4593 - Support regular expressions for CSS property matching (Closed) Base URL: https://bitbucket.org/fhd/adblockpluscore
Left Patch Set: Use String.prototype.startsWith/.endsWith Created Nov. 3, 2016, 7:05 p.m.
Right Patch Set: Don't detect '/' as a regexp and speed up regexp detection Created Nov. 8, 2016, 5: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 | test/filterClasses.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-2016 Eyeo GmbH 3 * Copyright (C) 2006-2016 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 1025 matching lines...) Expand 10 before | Expand all | Expand 10 after
1036 */ 1036 */
1037 get regexpString() 1037 get regexpString()
1038 { 1038 {
1039 // Despite this property being cached, the getter is called 1039 // Despite this property being cached, the getter is called
1040 // several times on Safari, due to WebKit bug 132872 1040 // several times on Safari, due to WebKit bug 132872
1041 let prop = Object.getOwnPropertyDescriptor(this, "regexpString"); 1041 let prop = Object.getOwnPropertyDescriptor(this, "regexpString");
1042 if (prop) 1042 if (prop)
1043 return prop.value; 1043 return prop.value;
1044 1044
1045 let regexp; 1045 let regexp;
1046 if (this.regexpSource.startsWith("/") && this.regexpSource.endsWith("/")) 1046 if (this.regexpSource.length >= 2 && this.regexpSource[0] == "/" &&
Wladimir Palant 2016/11/08 09:56:41 This is a potentially performance-sensitive code p
Felix Dahlke 2016/11/08 15:46:36 I'm not so sure about the performance impact of th
Felix Dahlke 2016/11/08 17:28:39 Done.
1047 this.regexpSource[this.regexpSource.length - 1] == "/")
Wladimir Palant 2016/11/08 17:41:34 Well, accessing this.regexpSource four times is ob
1047 regexp = this.regexpSource.slice(1, -1); 1048 regexp = this.regexpSource.slice(1, -1);
1048 else 1049 else
1049 regexp = Filter.toRegExp(this.regexpSource); 1050 regexp = Filter.toRegExp(this.regexpSource);
1050 Object.defineProperty(this, "regexpString", {value: regexp}); 1051 Object.defineProperty(this, "regexpString", {value: regexp});
1051 return regexp; 1052 return regexp;
1052 } 1053 }
1053 }); 1054 });
LEFTRIGHT

Powered by Google App Engine
This is Rietveld