Changeset 27702 in webkit for trunk/JavaScriptCore/kjs/nodes.h


Ignore:
Timestamp:
Nov 11, 2007, 8:27:33 PM (18 years ago)
Author:
[email protected]
Message:

Reviewed by Sam Weinig.


Fixed http://bugs.webkit.org/show_bug.cgi?id=15902
15% of string-validate-input.js is spent compiling the same regular expression


Store a compiled representation of the regular expression in the AST.


Only a .2% SunSpider speedup overall, but a 10.6% speedup on
string-validate-input.js.

  • kjs/nodes.cpp: (KJS::RegExpNode::evaluate):
  • kjs/nodes.h: (KJS::RegExpNode::):
  • kjs/nodes2string.cpp: (KJS::RegExpNode::streamTo):
  • kjs/regexp.cpp: (KJS::RegExp::flags):
  • kjs/regexp.h: (KJS::RegExp::pattern):
  • kjs/regexp_object.cpp: (KJS::RegExpObjectImp::construct): (KJS::RegExpObjectImp::createRegExpImp):
  • kjs/regexp_object.h:
File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/JavaScriptCore/kjs/nodes.h

    r27695 r27702  
    2929#include "Parser.h"
    3030#include "internal.h"
     31#include "RegExp.h"
    3132#include "SymbolTable.h"
    3233#include <wtf/ListRefPtr.h>
     
    271272  public:
    272273    RegExpNode(const UString& pattern, const UString& flags) KJS_FAST_CALL
    273       : m_pattern(pattern), m_flags(flags) { }
    274     virtual JSValue* evaluate(ExecState*) KJS_FAST_CALL;
     274        : m_regExp(new RegExp(pattern, flags))
     275    {
     276    }
     277    JSValue* evaluate(ExecState*) KJS_FAST_CALL;
    275278    virtual void streamTo(SourceStream&) const KJS_FAST_CALL;
    276279    virtual Precedence precedence() const { return PrecPrimary; }
    277280  private:
    278     UString m_pattern;
    279     UString m_flags;
     281    RefPtr<RegExp> m_regExp;
    280282  };
    281283
Note: See TracChangeset for help on using the changeset viewer.