Changeset 61924 in webkit for trunk/JavaScriptCore
- Timestamp:
- Jun 25, 2010, 5:41:49 PM (15 years ago)
- Location:
- trunk/JavaScriptCore
- Files:
-
- 5 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/JavaScriptCore/ChangeLog
r61882 r61924 1 2010-06-25 Renata Hodovan <[email protected]> 2 3 Reviewed by Geoffrey Garen. 4 5 Merge RegExp constructor and RegExp::create methods into one. 6 Both of function are called with tree parameters and check whether 7 flags (the third param) is given or not. 8 Simplify hash lookups in RegExpCache::create with giving them an extra 9 iterator parameter. 10 https://bugs.webkit.org/show_bug.cgi?id=41055 11 12 * runtime/RegExp.cpp: 13 (JSC::RegExp::RegExp): 14 * runtime/RegExp.h: 15 * runtime/RegExpCache.cpp: 16 (JSC::RegExpCache::lookupOrCreate): 17 (JSC::RegExpCache::create): 18 * runtime/RegExpCache.h: 19 1 20 2010-06-25 Jedrzej Nowacki <[email protected]> 2 21 -
trunk/JavaScriptCore/runtime/RegExp.cpp
r61845 r61924 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 58 49 inline RegExp::RegExp(JSGlobalData* globalData, const UString& pattern, const UString& flags) 59 50 : m_pattern(pattern) … … 64 55 // NOTE: The global flag is handled on a case-by-case basis by functions like 65 56 // 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 } 73 65 compile(globalData); 74 66 } … … 80 72 } 81 73 #endif 82 83 PassRefPtr<RegExp> RegExp::create(JSGlobalData* globalData, const UString& pattern)84 {85 return adoptRef(new RegExp(globalData, pattern));86 }87 74 88 75 PassRefPtr<RegExp> RegExp::create(JSGlobalData* globalData, const UString& pattern, const UString& flags) -
trunk/JavaScriptCore/runtime/RegExp.h
r61845 r61924 38 38 class RegExp : public RefCounted<RegExp> { 39 39 public: 40 static PassRefPtr<RegExp> create(JSGlobalData* globalData, const UString& pattern);41 40 static PassRefPtr<RegExp> create(JSGlobalData* globalData, const UString& pattern, const UString& flags); 42 41 #if !ENABLE(YARR) … … 57 56 58 57 private: 59 RegExp(JSGlobalData* globalData, const UString& pattern);60 58 RegExp(JSGlobalData* globalData, const UString& pattern, const UString& flags); 61 59 -
trunk/JavaScriptCore/runtime/RegExpCache.cpp
r61845 r61924 38 38 if (!result.second) 39 39 return result.first->second; 40 else 41 return create(patternString, flags, result.first); 40 42 } 41 return create(patternString, flags );43 return create(patternString, flags, m_cacheMap.end()); 42 44 } 43 45 44 PassRefPtr<RegExp> RegExpCache::create(const UString& patternString, const UString& flags )46 PassRefPtr<RegExp> RegExpCache::create(const UString& patternString, const UString& flags, RegExpCacheMap::iterator iterator) 45 47 { 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); 48 RefPtr<RegExp> regExp = RegExp::create(m_globalData, patternString, flags); 52 49 53 50 if (patternString.size() >= maxCacheablePatternLength) … … 63 60 64 61 RegExpKey key = RegExpKey(flags, patternString); 65 m_cacheMap.set(key, regExp); 62 iterator->first = key; 63 iterator->second = regExp; 66 64 patternKeyArray[m_nextKeyToEvict].flagsValue = key.flagsValue; 67 65 patternKeyArray[m_nextKeyToEvict].pattern = patternString.rep(); -
trunk/JavaScriptCore/runtime/RegExpCache.h
r61845 r61924 36 36 37 37 class RegExpCache { 38 39 typedef HashMap<RegExpKey, RefPtr<RegExp> > RegExpCacheMap; 40 38 41 public: 39 42 PassRefPtr<RegExp> lookupOrCreate(const UString& patternString, const UString& flags); 40 PassRefPtr<RegExp> create(const UString& patternString, const UString& flags );43 PassRefPtr<RegExp> create(const UString& patternString, const UString& flags, RegExpCacheMap::iterator iterator); 41 44 RegExpCache(JSGlobalData* globalData); 42 45 … … 45 48 static const int maxCacheableEntries = 256; 46 49 47 typedef HashMap<RegExpKey, RefPtr<RegExp> > RegExpCacheMap;48 50 RegExpKey patternKeyArray[maxCacheableEntries]; 49 51 RegExpCacheMap m_cacheMap;
Note:
See TracChangeset
for help on using the changeset viewer.