Changeset 53323 in webkit for trunk/JavaScriptCore


Ignore:
Timestamp:
Jan 14, 2010, 11:48:03 PM (15 years ago)
Author:
[email protected]
Message:

https://bugs.webkit.org/show_bug.cgi?id=33705
UStringImpl::create() should use internal storage

Reviewed by Oliver Hunt.

When creating a UStringImpl copying of a UChar*, we can use an internal buffer,
by calling UStringImpl::tryCreateUninitialized().

Also, remove duplicate of copyChars from JSString, call UStringImpl's version.

Small (max 0.5%) progression on Sunspidey.

  • runtime/JSString.cpp:

(JSC::JSString::resolveRope):

  • runtime/UStringImpl.h:

(JSC::UStringImpl::create):

Location:
trunk/JavaScriptCore
Files:
3 edited

Legend:

Unmodified
Added
Removed
  • trunk/JavaScriptCore/ChangeLog

    r53320 r53323  
     12010-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
    1202010-01-14  Gavin Barraclough  <[email protected]>
    221
  • trunk/JavaScriptCore/runtime/JSString.cpp

    r53320 r53323  
    6565{
    6666    destructNonRecursive();
    67 }
    68 
    69 #define ROPE_COPY_CHARS_INLINE_CUTOFF 20
    70 
    71 static inline void copyChars(UChar* destination, const UChar* source, unsigned numCharacters)
    72 {
    73 #ifdef ROPE_COPY_CHARS_INLINE_CUTOFF
    74     if (numCharacters <= ROPE_COPY_CHARS_INLINE_CUTOFF) {
    75         for (unsigned i = 0; i < numCharacters; ++i)
    76             destination[i] = source[i];
    77         return;
    78     }
    79 #endif
    80     memcpy(destination, source, numCharacters * sizeof(UChar));
    8167}
    8268
     
    129115            unsigned length = string->size();
    130116            position -= length;
    131             copyChars(position, string->data(), length);
     117            UStringImpl::copyChars(position, string->data(), length);
    132118
    133119            // Was this the last item in the work queue?
  • trunk/JavaScriptCore/runtime/UStringImpl.h

    r53320 r53323  
    9696    {
    9797        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();
    102103    }
    103104
     
    166167    UStringImpl* ref() { m_refCount += s_refCountIncrement; return this; }
    167168    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     }
    176169
    177170    static void copyChars(UChar* destination, const UChar* source, unsigned numCharacters)
Note: See TracChangeset for help on using the changeset viewer.