al_9x wrote:
No, that was clear, I was actually wondering if the rx engine optimized it. In the case of a test rather than a match, it doesn't need to scan the full input string for the last * in a pattern.
If you've got time, you may want to investigate
the source.
However I tried to run the following on Fx 3.6.3 with a 2.6 Ghz CPU:
Code: Select all
var iterations = 500000;
var r = /.*/
// var r = /(?:)/ // empty regexp variant
// var r = { test: function() { return true } } // dummy variant
var arr = [];
for (var j = 10 * 1024; j-- > 0;) {
arr.push(String.fromCharCode(Math.round(Math.random() * 255)));
}
var str = arr.join("");
var t = Date.now();
for (var j = iterations; j-- > 0;) {
r.test(str);
}
alert((Date.now() - t) / iterations)
Looks like no optimization is done, since /.*/ runs about 4 times slower (on average, since it's very variable) than /(?:)/, whose timings are much more repeatable too. Obviously the dummy no-regexp test runs 2 or 3 times faster than the fastest regexp.
However the difference it practically negligible for the AddressMatcher use cases, since
allthe approaches run in the
microsecond range even on 10KB strings, which are rather unusual as URLs.
al_9x wrote:
did you intend for page level surrogates to be injectable into chrome/about pages?
Page level surrogates are meant to be injected in content pages matching their "sources" preference. So yes, even in chrome/about pages.
And if so, I am curious, for what scenario?
Live customization?