Changeset 65104 in webkit for trunk/JavaScriptCore/runtime/UString.h
- Timestamp:
- Aug 10, 2010, 5:16:38 PM (15 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/JavaScriptCore/runtime/UString.h
r65099 r65104 46 46 47 47 public: 48 typedef StringImpl Rep;49 50 public:51 48 UString() {} 52 49 UString(const char*); // Constructor for null-terminated string. … … 56 53 57 54 UString(const UString& s) 58 : m_ rep(s.m_rep)55 : m_impl(s.m_impl) 59 56 { 60 57 } … … 62 59 // Special constructor for cases where we overwrite an object in place. 63 60 UString(PlacementNewAdoptType) 64 : m_ rep(PlacementNewAdopt)61 : m_impl(PlacementNewAdopt) 65 62 { 66 63 } … … 69 66 static PassRefPtr<StringImpl> adopt(Vector<UChar, inlineCapacity>& vector) 70 67 { 71 return Rep::adopt(vector);68 return StringImpl::adopt(vector); 72 69 } 73 70 … … 94 91 const UChar* data() const 95 92 { 96 if (!m_ rep)93 if (!m_impl) 97 94 return 0; 98 return m_ rep->characters();95 return m_impl->characters(); 99 96 } 100 97 101 98 unsigned size() const 102 99 { 103 if (!m_ rep)100 if (!m_impl) 104 101 return 0; 105 return m_ rep->length();106 } 107 108 bool isNull() const { return !m_ rep; }109 bool isEmpty() const { return !m_ rep || !m_rep->length(); }102 return m_impl->length(); 103 } 104 105 bool isNull() const { return !m_impl; } 106 bool isEmpty() const { return !m_impl || !m_impl->length(); } 110 107 111 108 bool is8Bit() const; … … 131 128 UString substr(unsigned pos = 0, unsigned len = 0xFFFFFFFF) const; 132 129 133 static const UString& null() { return *s_nullUString; } 134 135 Rep* rep() const { return m_rep.get(); } 136 137 UString(PassRefPtr<Rep> r) 138 : m_rep(r) 130 StringImpl* impl() const { return m_impl.get(); } 131 132 UString(PassRefPtr<StringImpl> r) 133 : m_impl(r) 139 134 { 140 135 } … … 142 137 size_t cost() const 143 138 { 144 if (!m_ rep)139 if (!m_impl) 145 140 return 0; 146 return m_ rep->cost();141 return m_impl->cost(); 147 142 } 148 143 149 144 ALWAYS_INLINE ~UString() { } 150 145 private: 151 RefPtr<Rep> m_rep; 152 153 static UString* s_nullUString; 154 155 friend void initializeUString(); 146 RefPtr<StringImpl> m_impl; 147 156 148 friend bool operator==(const UString&, const UString&); 157 149 }; … … 159 151 ALWAYS_INLINE bool operator==(const UString& s1, const UString& s2) 160 152 { 161 UString::Rep* rep1 = s1.rep();162 UString::Rep* rep2 = s2.rep();153 StringImpl* rep1 = s1.impl(); 154 StringImpl* rep2 = s2.impl(); 163 155 unsigned size1 = 0; 164 156 unsigned size2 = 0; … … 227 219 inline int codePointCompare(const UString& s1, const UString& s2) 228 220 { 229 return codePointCompare(s1. rep(), s2.rep());221 return codePointCompare(s1.impl(), s2.impl()); 230 222 } 231 223 … … 245 237 static const unsigned minShareSize = Heap::minExtraCost / sizeof(UChar); 246 238 247 struct IdentifierRepHash : PtrHash<RefPtr<JSC::UString::Rep> > { 248 static unsigned hash(const RefPtr<JSC::UString::Rep>& key) { return key->existingHash(); } 249 static unsigned hash(JSC::UString::Rep* key) { return key->existingHash(); } 250 }; 251 252 void initializeUString(); 239 struct IdentifierRepHash : PtrHash<RefPtr<StringImpl> > { 240 static unsigned hash(const RefPtr<StringImpl>& key) { return key->existingHash(); } 241 static unsigned hash(StringImpl* key) { return key->existingHash(); } 242 }; 253 243 254 244 template<typename StringType> … … 652 642 template<typename T> struct StrHash; 653 643 654 template<> struct StrHash< JSC::UString::Rep*> {655 static unsigned hash(const JSC::UString::Rep* key) { return key->hash(); }656 static bool equal(const JSC::UString::Rep* a, const JSC::UString::Rep* b) { return ::equal(a, b); }644 template<> struct StrHash<StringImpl*> { 645 static unsigned hash(const StringImpl* key) { return key->hash(); } 646 static bool equal(const StringImpl* a, const StringImpl* b) { return ::equal(a, b); } 657 647 static const bool safeToCompareToEmptyOrDeleted = false; 658 648 }; 659 649 660 template<> struct StrHash<RefPtr< JSC::UString::Rep> > : public StrHash<JSC::UString::Rep*> {661 using StrHash< JSC::UString::Rep*>::hash;662 static unsigned hash(const RefPtr< JSC::UString::Rep>& key) { return key->hash(); }663 using StrHash< JSC::UString::Rep*>::equal;664 static bool equal(const RefPtr< JSC::UString::Rep>& a, const RefPtr<JSC::UString::Rep>& b) { return ::equal(a.get(), b.get()); }665 static bool equal(const JSC::UString::Rep* a, const RefPtr<JSC::UString::Rep>& b) { return ::equal(a, b.get()); }666 static bool equal(const RefPtr< JSC::UString::Rep>& a, const JSC::UString::Rep* b) { return ::equal(a.get(), b); }650 template<> struct StrHash<RefPtr<StringImpl> > : public StrHash<StringImpl*> { 651 using StrHash<StringImpl*>::hash; 652 static unsigned hash(const RefPtr<StringImpl>& key) { return key->hash(); } 653 using StrHash<StringImpl*>::equal; 654 static bool equal(const RefPtr<StringImpl>& a, const RefPtr<StringImpl>& b) { return ::equal(a.get(), b.get()); } 655 static bool equal(const StringImpl* a, const RefPtr<StringImpl>& b) { return ::equal(a, b.get()); } 656 static bool equal(const RefPtr<StringImpl>& a, const StringImpl* b) { return ::equal(a.get(), b); } 667 657 668 658 static const bool safeToCompareToEmptyOrDeleted = false;
Note:
See TracChangeset
for help on using the changeset viewer.