Changeset 39350 in webkit for trunk/JavaScriptCore
- Timestamp:
- Dec 16, 2008, 6:23:02 PM (16 years ago)
- Location:
- trunk/JavaScriptCore
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/JavaScriptCore/ChangeLog
r39348 r39350 1 2008-12-16 Darin Adler <[email protected]> 2 3 Reviewed and landed by Cameron Zwarich. 4 5 Preparatory work for fixing 6 7 Bug 22887: Make UString::Rep use RefCounted rather than implementing its own ref counting 8 <https://bugs.webkit.org/show_bug.cgi?id=22887> 9 10 Change the various string translators used by Identifier:add() so that 11 they never zero the ref count of a newly created UString::Rep. 12 13 * runtime/Identifier.cpp: 14 (JSC::CStringTranslator::translate): 15 (JSC::Identifier::add): 16 (JSC::UCharBufferTranslator::translate): 17 1 18 2008-12-16 Gavin Barraclough <[email protected]> 2 19 -
trunk/JavaScriptCore/runtime/Identifier.cpp
r38528 r39350 97 97 } 98 98 99 struct CStringTranslator 100 { 99 struct CStringTranslator { 101 100 static unsigned hash(const char* c) 102 101 { … … 117 116 118 117 UString::Rep* r = UString::Rep::create(d, static_cast<int>(length)).releaseRef(); 119 r->rc = 0;120 118 r->_hash = hash; 121 119 … … 144 142 return iter->second; 145 143 146 UString::Rep* addedString = *identifierTable.add<const char*, CStringTranslator>(c).first; 147 literalIdentifierTable.add(c, addedString); 148 149 return addedString; 144 pair<HashSet<UString::Rep*>::iterator, bool> addResult = identifierTable.add<const char*, CStringTranslator>(c); 145 146 // If the string is newly-translated, then we need to adopt it. 147 // The boolean in the pair tells us if that is so. 148 RefPtr<UString::Rep> addedString = addResult.second ? adoptRef(*addResult.first) : *addResult.first; 149 150 literalIdentifierTable.add(c, addedString.get()); 151 152 return addedString.release(); 150 153 } 151 154 … … 160 163 }; 161 164 162 struct UCharBufferTranslator 163 { 165 struct UCharBufferTranslator { 164 166 static unsigned hash(const UCharBuffer& buf) 165 167 { … … 179 181 180 182 UString::Rep* r = UString::Rep::create(d, buf.length).releaseRef(); 181 r->rc = 0;182 183 r->_hash = hash; 183 184 … … 198 199 } 199 200 UCharBuffer buf = {s, length}; 200 return *globalData->identifierTable->add<UCharBuffer, UCharBufferTranslator>(buf).first; 201 pair<HashSet<UString::Rep*>::iterator, bool> addResult = globalData->identifierTable->add<UCharBuffer, UCharBufferTranslator>(buf); 202 203 // If the string is newly-translated, then we need to adopt it. 204 // The boolean in the pair tells us if that is so. 205 return addResult.second ? adoptRef(*addResult.first) : *addResult.first; 201 206 } 202 207
Note:
See TracChangeset
for help on using the changeset viewer.