Changeset 53323 in webkit for trunk/JavaScriptCore
- Timestamp:
- Jan 14, 2010, 11:48:03 PM (15 years ago)
- Location:
- trunk/JavaScriptCore
- Files:
-
- 3 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/JavaScriptCore/ChangeLog
r53320 r53323 1 2010-01-14 Gavin Barraclough <[email protected]> 2 3 Reviewed by Oliver Hunt. 4 5 https://bugs.webkit.org/show_bug.cgi?id=33705 6 UStringImpl::create() should use internal storage 7 8 When creating a UStringImpl copying of a UChar*, we can use an internal buffer, 9 by calling UStringImpl::tryCreateUninitialized(). 10 11 Also, remove duplicate of copyChars from JSString, call UStringImpl's version. 12 13 Small (max 0.5%) progression on Sunspidey. 14 15 * runtime/JSString.cpp: 16 (JSC::JSString::resolveRope): 17 * runtime/UStringImpl.h: 18 (JSC::UStringImpl::create): 19 1 20 2010-01-14 Gavin Barraclough <[email protected]> 2 21 -
trunk/JavaScriptCore/runtime/JSString.cpp
r53320 r53323 65 65 { 66 66 destructNonRecursive(); 67 }68 69 #define ROPE_COPY_CHARS_INLINE_CUTOFF 2070 71 static inline void copyChars(UChar* destination, const UChar* source, unsigned numCharacters)72 {73 #ifdef ROPE_COPY_CHARS_INLINE_CUTOFF74 if (numCharacters <= ROPE_COPY_CHARS_INLINE_CUTOFF) {75 for (unsigned i = 0; i < numCharacters; ++i)76 destination[i] = source[i];77 return;78 }79 #endif80 memcpy(destination, source, numCharacters * sizeof(UChar));81 67 } 82 68 … … 129 115 unsigned length = string->size(); 130 116 position -= length; 131 copyChars(position, string->data(), length);117 UStringImpl::copyChars(position, string->data(), length); 132 118 133 119 // Was this the last item in the work queue? -
trunk/JavaScriptCore/runtime/UStringImpl.h
r53320 r53323 96 96 { 97 97 UChar* newBuffer; 98 if (!UStringImpl::allocChars(length).getValue(newBuffer)) 99 return &null(); 100 copyChars(newBuffer, buffer, length); 101 return adoptRef(new UStringImpl(newBuffer, length, BufferOwned)); 98 if (PassRefPtr<UStringImpl> impl = tryCreateUninitialized(length, newBuffer)) { 99 copyChars(newBuffer, buffer, length); 100 return impl; 101 } 102 return &null(); 102 103 } 103 104 … … 166 167 UStringImpl* ref() { m_refCount += s_refCountIncrement; return this; } 167 168 ALWAYS_INLINE void deref() { if (!(m_refCount -= s_refCountIncrement)) delete this; } 168 169 static WTF::PossiblyNull<UChar*> allocChars(size_t length)170 {171 ASSERT(length);172 if (length > std::numeric_limits<size_t>::max() / sizeof(UChar))173 return 0;174 return tryFastMalloc(sizeof(UChar) * length);175 }176 169 177 170 static void copyChars(UChar* destination, const UChar* source, unsigned numCharacters)
Note:
See TracChangeset
for help on using the changeset viewer.