<?xml version="1.0" encoding="UTF-8" standalone="yes" ?>
<!DOCTYPE bugzilla SYSTEM "https://bugs.webkit.org/page.cgi?id=bugzilla.dtd">

<bugzilla version="5.0.4.1"
          urlbase="https://bugs.webkit.org/"
          
          maintainer="admin@webkit.org"
>

    <bug>
          <bug_id>22303</bug_id>
          
          <creation_ts>2008-11-16 21:27:37 -0800</creation_ts>
          <short_desc>Optimize /^x/ regexps to fail fast</short_desc>
          <delta_ts>2011-07-05 14:26:01 -0700</delta_ts>
          <reporter_accessible>1</reporter_accessible>
          <cclist_accessible>1</cclist_accessible>
          <classification_id>1</classification_id>
          <classification>Unclassified</classification>
          <product>WebKit</product>
          <component>JavaScriptCore</component>
          <version>528+ (Nightly build)</version>
          <rep_platform>Mac</rep_platform>
          <op_sys>OS X 10.5</op_sys>
          <bug_status>RESOLVED</bug_status>
          <resolution>WORKSFORME</resolution>
          
          
          <bug_file_loc></bug_file_loc>
          <status_whiteboard></status_whiteboard>
          <keywords></keywords>
          <priority>P2</priority>
          <bug_severity>Normal</bug_severity>
          <target_milestone>---</target_milestone>
          
          
          <everconfirmed>1</everconfirmed>
          <reporter name="Geoffrey Garen">ggaren</reporter>
          <assigned_to name="Geoffrey Garen">ggaren</assigned_to>
          <cc>barraclough</cc>
          

      

      

      

          <comment_sort_order>oldest_to_newest</comment_sort_order>  
          <long_desc isprivate="0" >
    <commentid>98998</commentid>
    <comment_count>0</comment_count>
    <who name="Geoffrey Garen">ggaren</who>
    <bug_when>2008-11-16 21:27:37 -0800</bug_when>
    <thetext>See bug 18086 -- let&apos;s do that optimization in WREC.

Here&apos;s what I think can be a layout test:

// Check that an initial ^ will result in a faster match fail.
var s = &quot;a&quot;;
var i;

for (i = 0; i &lt; 20; i++)
  s = s + s;

function test(string, regexp)
{
    var start = new Date;
    for (i = 0; i &lt; 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 &gt; .75)
    testPassed(&quot;Congrats, your browser didn&apos;t hang!&quot;);

testFailed(&quot;/^b/ did not discover a match failure faster than /b/&quot;);

var successfullyParsed = true;</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>432405</commentid>
    <comment_count>1</comment_count>
    <who name="Gavin Barraclough">barraclough</who>
    <bug_when>2011-07-05 14:26:01 -0700</bug_when>
    <thetext>This optimization now exists in YARR.</thetext>
  </long_desc>
      
      

    </bug>

</bugzilla>