Ignore:
Timestamp:
Jun 24, 2010, 11:33:48 PM (15 years ago)
Author:
[email protected]
Message:

Merge RegExp constructor and RegExp::create methods into one.
Both of function are called with tree parameters and check whether
flags (the third param) is given or not.
Simplify hash lookups in RegExpCache::create with giving them an extra
iterator parameter.
https://bugs.webkit.org/show_bug.cgi?id=41055

Patch by Renata Hodovan <[email protected]> on 2010-06-24
Reviewed by Geoffrey Garen.

  • runtime/RegExp.cpp:

(JSC::RegExp::RegExp):

  • runtime/RegExp.h:
  • runtime/RegExpCache.cpp:

(JSC::RegExpCache::lookupOrCreate):
(JSC::RegExpCache::create):

  • runtime/RegExpCache.h:
File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/JavaScriptCore/runtime/RegExp.cpp

    r59355 r61833  
    4747namespace JSC {
    4848
    49 inline RegExp::RegExp(JSGlobalData* globalData, const UString& pattern)
    50     : m_pattern(pattern)
    51     , m_flagBits(0)
    52     , m_constructionError(0)
    53     , m_numSubpatterns(0)
    54 {
    55     compile(globalData);
    56 }
    57 
    5849inline RegExp::RegExp(JSGlobalData* globalData, const UString& pattern, const UString& flags)
    5950    : m_pattern(pattern)
     
    6455    // NOTE: The global flag is handled on a case-by-case basis by functions like
    6556    // String::match and RegExpObject::match.
    66     if (flags.find('g') != UString::NotFound)
    67         m_flagBits |= Global;
    68     if (flags.find('i') != UString::NotFound)
    69         m_flagBits |= IgnoreCase;
    70     if (flags.find('m') != UString::NotFound)
    71         m_flagBits |= Multiline;
    72 
     57    if (!flags.isNull()) {
     58        if (flags.find('g') != UString::NotFound)
     59            m_flagBits |= Global;
     60        if (flags.find('i') != UString::NotFound)
     61            m_flagBits |= IgnoreCase;
     62        if (flags.find('m') != UString::NotFound)
     63            m_flagBits |= Multiline;
     64    }
    7365    compile(globalData);
    7466}
     
    8072}
    8173#endif
    82 
    83 PassRefPtr<RegExp> RegExp::create(JSGlobalData* globalData, const UString& pattern)
    84 {
    85     return adoptRef(new RegExp(globalData, pattern));
    86 }
    8774
    8875PassRefPtr<RegExp> RegExp::create(JSGlobalData* globalData, const UString& pattern, const UString& flags)
Note: See TracChangeset for help on using the changeset viewer.