Changeset 65286 in webkit for trunk/JavaScriptCore/runtime
- Timestamp:
- Aug 12, 2010, 6:05:10 PM (15 years ago)
- Location:
- trunk/JavaScriptCore/runtime
- Files:
-
- 4 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/JavaScriptCore/runtime/RegExpKey.h
r65104 r65286 59 59 } 60 60 61 RegExpKey(int flags, const RefPtr<StringImpl>& pattern) 62 : flagsValue(flags) 63 , pattern(pattern) 64 { 65 } 66 61 67 RegExpKey(const UString& flags, const UString& pattern) 62 68 : pattern(pattern.impl()) -
trunk/JavaScriptCore/runtime/SmallStrings.cpp
r65104 r65286 130 130 m_storage = adoptPtr(new SmallStringsStorage); 131 131 ASSERT(!m_singleCharacterStrings[character]); 132 m_singleCharacterStrings[character] = new (globalData) JSString(globalData, m_storage->rep(character), JSString::HasOtherOwner);132 m_singleCharacterStrings[character] = new (globalData) JSString(globalData, PassRefPtr<StringImpl>(m_storage->rep(character)), JSString::HasOtherOwner); 133 133 } 134 134 -
trunk/JavaScriptCore/runtime/UString.cpp
r65266 r65286 57 57 COMPILE_ASSERT(sizeof(UString) == sizeof(void*), UString_should_stay_small); 58 58 59 UString::UString(const char* c) 60 : m_impl(StringImpl::create(c)) 61 { 62 } 63 64 UString::UString(const char* c, unsigned length) 65 : m_impl(StringImpl::create(c, length)) 66 { 67 } 68 69 UString::UString(const UChar* c, unsigned length) 70 : m_impl(StringImpl::create(c, length)) 71 { 72 } 59 // UString::UString(const UChar* characters, unsigned length) 60 // : m_impl(characters ? StringImpl::create(characters, length) : 0) 61 // { 62 // } 63 UString::UString(const UChar* characters) 64 { 65 if (!characters) 66 return; 67 68 int length = 0; 69 while (characters[length] != UChar(0)) 70 ++length; 71 72 m_impl = StringImpl::create(characters, length); 73 } 74 // UString::UString(const char* characters) 75 // : m_impl(characters ? StringImpl::create(characters) : 0) 76 // { 77 // } 78 // UString::UString(const char* characters, unsigned length) 79 // : m_impl(characters ? StringImpl::create(characters, length) : 0) 80 // { 81 // } 73 82 74 83 UString UString::number(int i) … … 209 218 210 219 return asciiBuffer; 211 }212 213 UChar UString::operator[](unsigned pos) const214 {215 if (pos >= length())216 return '\0';217 return characters()[pos];218 220 } 219 221 -
trunk/JavaScriptCore/runtime/UString.h
r65268 r65286 44 44 class UString { 45 45 public: 46 UString() {} 47 UString(const char*); // Constructor for null-terminated string. 48 UString(const char*, unsigned length); 49 UString(const UChar*, unsigned length); 50 UString(const Vector<UChar>& buffer); 51 52 UString(const UString& s) 53 : m_impl(s.m_impl) 54 { 55 } 56 57 // Special constructor for cases where we overwrite an object in place. 58 UString(PlacementNewAdoptType) 59 : m_impl(PlacementNewAdopt) 60 { 61 } 46 // Construct a null string, distinguishable from an empty string. 47 UString() { } 48 49 // Construct a string with UTF-16 data. 50 UString(const UChar* characters, unsigned length) 51 : m_impl(characters ? StringImpl::create(characters, length) : 0) 52 { 53 } 54 55 // Construct a string with UTF-16 data, from a null-terminated source. 56 UString(const UChar*); 57 58 // Construct a string with latin1 data. 59 UString(const char* characters) 60 : m_impl(characters ? StringImpl::create(characters) : 0) 61 { 62 } 63 64 // Construct a string with latin1 data, from a null-terminated source. 65 UString(const char* characters, unsigned length) 66 : m_impl(characters ? StringImpl::create(characters, length) : 0) 67 { 68 } 69 70 // Construct a string referencing an existing StringImpl. 71 UString(StringImpl* impl) : m_impl(impl) { } 72 UString(PassRefPtr<StringImpl> impl) : m_impl(impl) { } 73 UString(RefPtr<StringImpl> impl) : m_impl(impl) { } 74 75 void swap(UString& o) { m_impl.swap(o.m_impl); } 62 76 63 77 template<size_t inlineCapacity> 64 static PassRefPtr<StringImpl> adopt(Vector<UChar, inlineCapacity>& vector) 65 { 66 return StringImpl::adopt(vector); 67 } 78 static UString adopt(Vector<UChar, inlineCapacity>& vector) { return StringImpl::adopt(vector); } 68 79 69 80 static UString number(int); … … 101 112 } 102 113 103 UChar operator[](unsigned pos) const; 114 UChar operator[](unsigned index) const 115 { 116 if (!m_impl || index >= m_impl->length()) 117 return 0; 118 return m_impl->characters()[index]; 119 } 104 120 105 121 double toDouble(bool tolerateTrailingJunk, bool tolerateEmptyString) const; … … 125 141 126 142 StringImpl* impl() const { return m_impl.get(); } 127 128 UString(PassRefPtr<StringImpl> r)129 : m_impl(r)130 {131 }132 143 133 144 size_t cost() const
Note:
See TracChangeset
for help on using the changeset viewer.