diff options
author | Steve Block <steveblock@google.com> | 2010-02-02 14:57:50 +0000 |
---|---|---|
committer | Steve Block <steveblock@google.com> | 2010-02-04 15:06:55 +0000 |
commit | d0825bca7fe65beaee391d30da42e937db621564 (patch) | |
tree | 7461c49eb5844ffd1f35d1ba2c8b7584c1620823 /JavaScriptCore/runtime/JSString.cpp | |
parent | 3db770bd97c5a59b6c7574ca80a39e5a51c1defd (diff) | |
download | external_webkit-d0825bca7fe65beaee391d30da42e937db621564.zip external_webkit-d0825bca7fe65beaee391d30da42e937db621564.tar.gz external_webkit-d0825bca7fe65beaee391d30da42e937db621564.tar.bz2 |
Merge webkit.org at r54127 : Initial merge by git
Change-Id: Ib661abb595522f50ea406f72d3a0ce17f7193c82
Diffstat (limited to 'JavaScriptCore/runtime/JSString.cpp')
-rw-r--r-- | JavaScriptCore/runtime/JSString.cpp | 32 |
1 files changed, 11 insertions, 21 deletions
diff --git a/JavaScriptCore/runtime/JSString.cpp b/JavaScriptCore/runtime/JSString.cpp index 28ae6f7..1e23a15 100644 --- a/JavaScriptCore/runtime/JSString.cpp +++ b/JavaScriptCore/runtime/JSString.cpp @@ -66,20 +66,6 @@ JSString::Rope::~Rope() destructNonRecursive(); } -#define ROPE_COPY_CHARS_INLINE_CUTOFF 20 - -static inline void copyChars(UChar* destination, const UChar* source, unsigned numCharacters) -{ -#ifdef ROPE_COPY_CHARS_INLINE_CUTOFF - if (numCharacters <= ROPE_COPY_CHARS_INLINE_CUTOFF) { - for (unsigned i = 0; i < numCharacters; ++i) - destination[i] = source[i]; - return; - } -#endif - memcpy(destination, source, numCharacters * sizeof(UChar)); -} - // Overview: this methods converts a JSString from holding a string in rope form // down to a simple UString representation. It does so by building up the string // backwards, since we want to avoid recursion, we expect that the tree structure @@ -96,13 +82,16 @@ void JSString::resolveRope(ExecState* exec) const // Allocate the buffer to hold the final string, position initially points to the end. UChar* buffer; - if (!tryFastMalloc(m_stringLength * sizeof(UChar)).getValue(buffer)) { - for (unsigned i = 0; i < m_ropeLength; ++i) + if (PassRefPtr<UStringImpl> newImpl = UStringImpl::tryCreateUninitialized(m_stringLength, buffer)) + m_value = newImpl; + else { + for (unsigned i = 0; i < m_ropeLength; ++i) { m_fibers[i].deref(); + m_fibers[i] = static_cast<void*>(0); + } m_ropeLength = 0; ASSERT(!isRope()); ASSERT(m_value == UString()); - throwOutOfMemoryError(exec); return; } @@ -125,17 +114,18 @@ void JSString::resolveRope(ExecState* exec) const currentFiber = rope->fibers(ropeLengthMinusOne); } else { UString::Rep* string = currentFiber.string(); - unsigned length = string->len; + unsigned length = string->size(); position -= length; - copyChars(position, string->data(), length); + UStringImpl::copyChars(position, string->data(), length); // Was this the last item in the work queue? if (workQueue.isEmpty()) { // Create a string from the UChar buffer, clear the rope RefPtr. ASSERT(buffer == position); - m_value = UString::Rep::create(buffer, m_stringLength); - for (unsigned i = 0; i < m_ropeLength; ++i) + for (unsigned i = 0; i < m_ropeLength; ++i) { m_fibers[i].deref(); + m_fibers[i] = static_cast<void*>(0); + } m_ropeLength = 0; ASSERT(!isRope()); |