Changeset 58712 in webkit for trunk/JavaScriptCore/wtf/text/StringImpl.h
- Timestamp:
- May 3, 2010, 4:03:37 PM (15 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/JavaScriptCore/wtf/text/StringImpl.h
r58392 r58712 44 44 // FIXME: This is a temporary layering violation while we move string code to WTF. 45 45 // Landing the file moves in one patch, will follow on with patches to change the namespaces. 46 namespace WTF { 47 48 struct CStringTranslator; 49 struct UCharBufferTranslator; 50 struct HashAndCharactersTranslator; 46 namespace JSC { 47 48 struct IdentifierCStringTranslator; 49 struct IdentifierUCharBufferTranslator; 51 50 52 51 } … … 58 57 class StringBuffer; 59 58 59 struct CStringTranslator; 60 struct HashAndCharactersTranslator; 60 61 struct StringHash; 62 struct UCharBufferTranslator; 61 63 62 64 enum TextCaseSensitivity { TextCaseSensitive, TextCaseInsensitive }; … … 67 69 68 70 class StringImpl : public StringImplBase { 69 friend struct WTF::CStringTranslator; 70 friend struct WTF::UCharBufferTranslator; 71 friend struct WTF::HashAndCharactersTranslator; 71 friend struct JSC::IdentifierCStringTranslator; 72 friend struct JSC::IdentifierUCharBufferTranslator; 73 friend struct CStringTranslator; 74 friend struct HashAndCharactersTranslator; 75 friend struct UCharBufferTranslator; 72 76 friend class AtomicStringImpl; 73 77 private: … … 220 224 bool hasTerminatingNullCharacter() const { return m_refCountAndFlags & s_refCountFlagHasTerminatingNullCharacter; } 221 225 222 bool isAtomic() const { return m_refCountAndFlags & s_refCountFlagIsAtomic; } 223 void setIsAtomic(bool inTable) 224 { 225 ASSERT(!isStatic()); 226 if (inTable) 227 m_refCountAndFlags |= s_refCountFlagIsAtomic; 228 else 229 m_refCountAndFlags &= s_refCountFlagIsAtomic; 230 } 226 bool inTable() const { return m_refCountAndFlags & s_refCountFlagInTable; } 227 void setInTable() { m_refCountAndFlags |= s_refCountFlagInTable; } 231 228 232 229 unsigned hash() const { if (!m_hash) m_hash = computeHash(m_data, m_length); return m_hash; } … … 336 333 bool equal(const StringImpl*, const char*); 337 334 inline bool equal(const char* a, StringImpl* b) { return equal(b, a); } 338 inline bool equal(StringImpl* string, const UChar* characters, unsigned length)339 {340 if (string->length() != length)341 return false;342 343 // FIXME: perhaps we should have a more abstract macro that indicates when344 // going 4 bytes at a time is unsafe345 #if CPU(ARM) || CPU(SH4)346 const UChar* stringCharacters = string->characters();347 for (unsigned i = 0; i != length; ++i) {348 if (*stringCharacters++ != *characters++)349 return false;350 }351 return true;352 #else353 /* Do it 4-bytes-at-a-time on architectures where it's safe */354 355 const uint32_t* stringCharacters = reinterpret_cast<const uint32_t*>(string->characters());356 const uint32_t* bufferCharacters = reinterpret_cast<const uint32_t*>(characters);357 358 unsigned halfLength = length >> 1;359 for (unsigned i = 0; i != halfLength; ++i) {360 if (*stringCharacters++ != *bufferCharacters++)361 return false;362 }363 364 if (length & 1 && *reinterpret_cast<const uint16_t*>(stringCharacters) != *reinterpret_cast<const uint16_t*>(bufferCharacters))365 return false;366 367 return true;368 #endif369 }370 335 371 336 bool equalIgnoringCase(StringImpl*, StringImpl*); … … 410 375 411 376 using WebCore::equal; 412 using WebCore::StringImpl;413 377 414 378 namespace WTF {
Note:
See TracChangeset
for help on using the changeset viewer.