Changeset 61927 in webkit for trunk/JavaScriptCore/runtime
- Timestamp:
- Jun 25, 2010, 6:04:28 PM (15 years ago)
- Location:
- trunk/JavaScriptCore/runtime
- Files:
-
- 4 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/JavaScriptCore/runtime/RegExp.cpp
r61924 r61927 47 47 namespace JSC { 48 48 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 49 58 inline RegExp::RegExp(JSGlobalData* globalData, const UString& pattern, const UString& flags) 50 59 : m_pattern(pattern) … … 55 64 // NOTE: The global flag is handled on a case-by-case basis by functions like 56 65 // String::match and RegExpObject::match. 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 } 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 65 73 compile(globalData); 66 74 } … … 72 80 } 73 81 #endif 82 83 PassRefPtr<RegExp> RegExp::create(JSGlobalData* globalData, const UString& pattern) 84 { 85 return adoptRef(new RegExp(globalData, pattern)); 86 } 74 87 75 88 PassRefPtr<RegExp> RegExp::create(JSGlobalData* globalData, const UString& pattern, const UString& flags) -
trunk/JavaScriptCore/runtime/RegExp.h
r61924 r61927 38 38 class RegExp : public RefCounted<RegExp> { 39 39 public: 40 static PassRefPtr<RegExp> create(JSGlobalData* globalData, const UString& pattern); 40 41 static PassRefPtr<RegExp> create(JSGlobalData* globalData, const UString& pattern, const UString& flags); 41 42 #if !ENABLE(YARR) … … 56 57 57 58 private: 59 RegExp(JSGlobalData* globalData, const UString& pattern); 58 60 RegExp(JSGlobalData* globalData, const UString& pattern, const UString& flags); 59 61 -
trunk/JavaScriptCore/runtime/RegExpCache.cpp
r61924 r61927 38 38 if (!result.second) 39 39 return result.first->second; 40 else41 return create(patternString, flags, result.first);42 40 } 43 return create(patternString, flags , m_cacheMap.end());41 return create(patternString, flags); 44 42 } 45 43 46 PassRefPtr<RegExp> RegExpCache::create(const UString& patternString, const UString& flags , RegExpCacheMap::iterator iterator)44 PassRefPtr<RegExp> RegExpCache::create(const UString& patternString, const UString& flags) 47 45 { 48 RefPtr<RegExp> regExp = RegExp::create(m_globalData, patternString, flags); 46 RefPtr<RegExp> regExp; 47 48 if (!flags.isNull()) 49 regExp = RegExp::create(m_globalData, patternString, flags); 50 else 51 regExp = RegExp::create(m_globalData, patternString); 49 52 50 53 if (patternString.size() >= maxCacheablePatternLength) … … 60 63 61 64 RegExpKey key = RegExpKey(flags, patternString); 62 iterator->first = key; 63 iterator->second = regExp; 65 m_cacheMap.set(key, regExp); 64 66 patternKeyArray[m_nextKeyToEvict].flagsValue = key.flagsValue; 65 67 patternKeyArray[m_nextKeyToEvict].pattern = patternString.rep(); -
trunk/JavaScriptCore/runtime/RegExpCache.h
r61924 r61927 36 36 37 37 class RegExpCache { 38 39 typedef HashMap<RegExpKey, RefPtr<RegExp> > RegExpCacheMap;40 41 38 public: 42 39 PassRefPtr<RegExp> lookupOrCreate(const UString& patternString, const UString& flags); 43 PassRefPtr<RegExp> create(const UString& patternString, const UString& flags , RegExpCacheMap::iterator iterator);40 PassRefPtr<RegExp> create(const UString& patternString, const UString& flags); 44 41 RegExpCache(JSGlobalData* globalData); 45 42 … … 48 45 static const int maxCacheableEntries = 256; 49 46 47 typedef HashMap<RegExpKey, RefPtr<RegExp> > RegExpCacheMap; 50 48 RegExpKey patternKeyArray[maxCacheableEntries]; 51 49 RegExpCacheMap m_cacheMap;
Note:
See TracChangeset
for help on using the changeset viewer.