Changeset 152289 in webkit
- Timestamp:
- Jul 2, 2013 6:36:09 AM (11 years ago)
- Location:
- trunk/Source/WTF
- Files:
-
- 3 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/Source/WTF/ChangeLog
r152201 r152289 1 2013-07-02 Mikhail Pozdnyakov <mikhail.pozdnyakov@intel.com> 2 3 Avoid code duplication inside String::append() 4 https://bugs.webkit.org/show_bug.cgi?id=118290 5 6 Reviewed by Anders Carlsson. 7 8 The implementation of 'append(UChar)' had been repeated inside 'append(LChar)', 9 this duplication is obviated now. 10 11 * wtf/text/WTFString.cpp: 12 (WTF::String::appendInternal): 13 (WTF::String::append): 14 * wtf/text/WTFString.h: 15 1 16 2013-06-28 Anders Carlsson <andersca@apple.com> 2 17 -
trunk/Source/WTF/wtf/text/WTFString.cpp
r152201 r152289 120 120 } 121 121 122 void String::append(LChar c) 122 template <typename CharacterType> 123 inline void String::appendInternal(CharacterType c) 123 124 { 124 125 // FIXME: This is extremely inefficient. So much so that we might want to take this … … 138 139 } 139 140 141 void String::append(LChar c) 142 { 143 appendInternal(c); 144 } 145 140 146 void String::append(UChar c) 141 147 { 142 // FIXME: This is extremely inefficient. So much so that we might want to take this 143 // out of String's API. We can make it better by optimizing the case where exactly 144 // one String is pointing at this StringImpl, but even then it's going to require a 145 // call to fastMalloc every single time. 146 if (m_impl) { 147 UChar* data; 148 if (m_impl->length() >= numeric_limits<unsigned>::max()) 149 CRASH(); 150 RefPtr<StringImpl> newImpl = StringImpl::createUninitialized(m_impl->length() + 1, data); 151 memcpy(data, m_impl->characters(), m_impl->length() * sizeof(UChar)); 152 data[m_impl->length()] = c; 153 m_impl = newImpl.release(); 154 } else 155 m_impl = StringImpl::create(&c, 1); 148 appendInternal(c); 156 149 } 157 150 -
trunk/Source/WTF/wtf/text/WTFString.h
r152201 r152289 495 495 template <typename CharacterType> 496 496 void removeInternal(const CharacterType*, unsigned, int); 497 498 template <typename CharacterType> 499 void appendInternal(CharacterType); 497 500 498 501 RefPtr<StringImpl> m_impl;
Note: See TracChangeset
for help on using the changeset viewer.