[Webkit-unassigned] [Bug 81459] New: Strength reduction, RegExp.exec -> RegExp.test
bugzilla-daemon at webkit.org
bugzilla-daemon at webkit.org
Sat Mar 17 17:15:47 PDT 2012
https://bugs.webkit.org/show_bug.cgi?id=81459
Summary: Strength reduction, RegExp.exec -> RegExp.test
Product: WebKit
Version: 528+ (Nightly build)
Platform: Unspecified
OS/Version: Unspecified
Status: NEW
Severity: Normal
Priority: P2
Component: JavaScriptCore
AssignedTo: webkit-unassigned at lists.webkit.org
ReportedBy: barraclough at apple.com
RegExp.prototype.exec & RegExp.prototype.test can both be used to test a regular expression for a match against a string - however exec is more expensive, since it allocates a matches array object. In cases where the result is consumed in a boolean context the allocation of the matches array can be trivially elided.
For example:
function f()
{
for (i =0; i < 10000000; ++i)
if(!/a/.exec("a"))
err = true;
}
This is a 2.5x speedup on this example microbenchmark loop.
In a more advanced for of this optimization, we may be able to avoid allocating the array where access to the array can be observed.
--
Configure bugmail: https://bugs.webkit.org/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
You are the assignee for the bug.
More information about the webkit-unassigned
mailing list