Bug 22303

Summary: Optimize /^x/ regexps to fail fast
Product: WebKit Reporter: Geoffrey Garen <ggaren>
Component: JavaScriptCoreAssignee: 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
Reported 2008-11-16 21:27:37 PST
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
Gavin Barraclough
Comment 1 2011-07-05 14:26:01 PDT
This optimization now exists in YARR.
Note You need to log in before you can comment on or make changes to this bug.