Bug 22303
Summary: | Optimize /^x/ regexps to fail fast | ||
---|---|---|---|
Product: | WebKit | Reporter: | Geoffrey Garen <ggaren> |
Component: | JavaScriptCore | Assignee: | Geoffrey Garen <ggaren> |
Status: | RESOLVED WORKSFORME | ||
Severity: | Normal | CC: | barraclough |
Priority: | P2 | ||
Version: | 528+ (Nightly build) | ||
Hardware: | Mac | ||
OS: | OS X 10.5 |
Geoffrey Garen
See bug 18086 -- let's do that optimization in WREC.
Here's what I think can be a layout test:
// Check that an initial ^ will result in a faster match fail.
var s = "a";
var i;
for (i = 0; i < 20; i++)
s = s + s;
function test(string, regexp)
{
var start = new Date;
for (i = 0; i < 100; i++)
regexp.test(s);
return new Date - start;
}
var result1 = test(s, /b/);
var result2 = test(s, /^b/);
alert(result1);
alert(result2);
if ((result1 - result2) / result1 > .75)
testPassed("Congrats, your browser didn't hang!");
testFailed("/^b/ did not discover a match failure faster than /b/");
var successfullyParsed = true;
Attachments | ||
---|---|---|
Add attachment proposed patch, testcase, etc. |
Gavin Barraclough
This optimization now exists in YARR.