Ignore:
Timestamp:
Feb 10, 2014, 12:39:12 PM (11 years ago)
Author:
[email protected]
Message:

Make the Identifier::add() family return PassRef<StringImpl>.
<https://webkit.org/b/128542>

This knocks one branch off of creating an Identifier from another
string source.

Reviewed by Oliver Hunt.

  • runtime/Identifier.cpp:

(JSC::Identifier::add):
(JSC::Identifier::add8):
(JSC::Identifier::addSlowCase):

  • runtime/Identifier.h:

(JSC::Identifier::add):

  • runtime/Lookup.cpp:

(JSC::HashTable::createTable):

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/Source/JavaScriptCore/runtime/Identifier.h

    r162784 r163808  
    9696
    9797        // Only to be used with string literals.
    98         static PassRefPtr<StringImpl> add(VM*, const char*);
    99         JS_EXPORT_PRIVATE static PassRefPtr<StringImpl> add(ExecState*, const char*);
     98        static PassRef<StringImpl> add(VM*, const char*);
     99        JS_EXPORT_PRIVATE static PassRef<StringImpl> add(ExecState*, const char*);
    100100
    101101    private:
     
    108108        static bool equal(const Identifier& a, const LChar* b) { return equal(a.m_string.impl(), b); }
    109109
    110         template <typename T> static PassRefPtr<StringImpl> add(VM*, const T*, int length);
    111         static PassRefPtr<StringImpl> add8(VM*, const UChar*, int length);
     110        template <typename T> static PassRef<StringImpl> add(VM*, const T*, int length);
     111        static PassRef<StringImpl> add8(VM*, const UChar*, int length);
    112112        template <typename T> ALWAYS_INLINE static bool canUseSingleCharacterString(T);
    113113
    114         static PassRefPtr<StringImpl> add(ExecState* exec, StringImpl* r)
     114        static PassRef<StringImpl> add(ExecState* exec, StringImpl* r)
    115115        {
    116116#ifndef NDEBUG
     
    118118#endif
    119119            if (r->isIdentifier())
    120                 return r;
     120                return *r;
    121121            return addSlowCase(exec, r);
    122122        }
    123         static PassRefPtr<StringImpl> add(VM* vm, StringImpl* r)
     123        static PassRef<StringImpl> add(VM* vm, StringImpl* r)
    124124        {
    125125#ifndef NDEBUG
     
    127127#endif
    128128            if (r->isIdentifier())
    129                 return r;
     129                return *r;
    130130            return addSlowCase(vm, r);
    131131        }
    132132
    133         JS_EXPORT_PRIVATE static PassRefPtr<StringImpl> addSlowCase(ExecState*, StringImpl* r);
    134         JS_EXPORT_PRIVATE static PassRefPtr<StringImpl> addSlowCase(VM*, StringImpl* r);
     133        JS_EXPORT_PRIVATE static PassRef<StringImpl> addSlowCase(ExecState*, StringImpl* r);
     134        JS_EXPORT_PRIVATE static PassRef<StringImpl> addSlowCase(VM*, StringImpl* r);
    135135
    136136        JS_EXPORT_PRIVATE static void checkCurrentIdentifierTable(ExecState*);
     
    179179
    180180    template <typename T>
    181     PassRefPtr<StringImpl> Identifier::add(VM* vm, const T* s, int length)
     181    PassRef<StringImpl> Identifier::add(VM* vm, const T* s, int length)
    182182    {
    183183        if (length == 1) {
     
    188188       
    189189        if (!length)
    190             return StringImpl::empty();
     190            return *StringImpl::empty();
    191191        CharBuffer<T> buf = { s, static_cast<unsigned>(length) };
    192192        HashSet<StringImpl*>::AddResult addResult = vm->identifierTable->add<CharBuffer<T>, IdentifierCharBufferTranslator<T>>(buf);
     
    194194        // If the string is newly-translated, then we need to adopt it.
    195195        // The boolean in the pair tells us if that is so.
    196         return addResult.isNewEntry ? adoptRef(*addResult.iterator) : *addResult.iterator;
     196        return addResult.isNewEntry ? adoptRef(**addResult.iterator) : **addResult.iterator;
    197197    }
    198198
Note: See TracChangeset for help on using the changeset viewer.