Filter Options are slow..? Any reason?
Posted: Thu Apr 19, 2007 4:02 pm
Hello hello. 
We were discussing about the performance of Filter Options, and found Adblock Plus checks any filters even if they have no effective Option. For example, it checks the filter "adbanner$script" for URLs of "image".
Current source of chrome/adblockplus.jar/content/prefs.js is:
We think this would skip filters with invalid Options and run faster:
Is there any reason for currrent (and probably slow) Filter Options?
Thanks for your reading.

We were discussing about the performance of Filter Options, and found Adblock Plus checks any filters even if they have no effective Option. For example, it checks the filter "adbanner$script" for URLs of "image".
Current source of chrome/adblockplus.jar/content/prefs.js is:
matchesAnyInternal: function(location, contentType) {
if (this.shortcuts > 0) {
// Optimized matching using shortcuts
var text = location.toLowerCase();
var endPos = text.length - shortcutLength + 1;
for (var i = 0; i <= endPos; i++) {
var substr = text.substr(i, shortcutLength);
var pattern = this.shortcutHash[substr];
if (typeof pattern != "undefined" && pattern.regexp.test(location) &&
(!("contentType" in pattern) || typeMap[contentType] & pattern.contentType))
return pattern;
}
}
var list = this.regexps;
for (i = 0; i < list.length; i++)
if (list.regexp.test(location) && (!("contentType" in list) || typeMap[contentType] & list.contentType))
return list;
return null;
},
We think this would skip filters with invalid Options and run faster:
matchesAnyInternal: function(location, contentType) {
if (this.shortcuts > 0) {
// Optimized matching using shortcuts
var text = location.toLowerCase();
var endPos = text.length - shortcutLength + 1;
for (var i = 0; i <= endPos; i++) {
var substr = text.substr(i, shortcutLength);
var pattern = this.shortcutHash[substr];
if (typeof pattern != "undefined" && (!("contentType" in pattern) || typeMap[contentType] & pattern.contentType) &&
pattern.regexp.test(location))
return pattern;
}
}
var list = this.regexps;
for (i = 0; i < list.length; i++)
if ((!("contentType" in list) || typeMap[contentType] & list.contentType) && list.regexp.test(location))
return list;
return null;
},
Is there any reason for currrent (and probably slow) Filter Options?

Thanks for your reading.
