Ignore:
Timestamp:
Dec 18, 2009, 2:59:18 PM (15 years ago)
Author:
[email protected]
Message:

Add createNonCopying method to UString to make replace constructor passed bool,
to make behaviour more explicit. Add createFromUTF8 to UString (wrapping method
on UString::Rep), since other cases of transliteration (e.g. from ascii) are
performed in UString constructors. Add/use setHash & size() accessors on Rep,
rather than accessing _hash/len directly.

Reviewed by Sam Weinig.

  • API/JSClassRef.cpp:

(OpaqueJSClass::OpaqueJSClass):

  • API/OpaqueJSString.cpp:

(OpaqueJSString::ustring):

(JSC::arrayProtoFuncToString):

  • runtime/Identifier.cpp:

(JSC::Identifier::equal):
(JSC::CStringTranslator::translate):
(JSC::UCharBufferTranslator::translate):
(JSC::Identifier::addSlowCase):

  • runtime/JSString.cpp:

(JSC::JSString::resolveRope):

  • runtime/JSString.h:

(JSC::JSString::Rope::Fiber::refAndGetLength):
(JSC::JSString::Rope::append):

  • runtime/StringBuilder.h:

(JSC::StringBuilder::release):

  • runtime/StringConstructor.cpp:

(JSC::stringFromCharCodeSlowCase):

  • runtime/StringPrototype.cpp:

(JSC::substituteBackreferencesSlow):
(JSC::stringProtoFuncToLowerCase):
(JSC::stringProtoFuncToUpperCase):
(JSC::stringProtoFuncFontsize):
(JSC::stringProtoFuncLink):

  • runtime/UString.cpp:

(JSC::UString::UString):
(JSC::UString::createNonCopying):
(JSC::UString::createFromUTF8):

  • runtime/UString.h:

(JSC::UString::Rep::setHash):
(JSC::UString::~UString):
(JSC::makeString):

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/JavaScriptCore/runtime/UString.h

    r52082 r52346  
    118118            unsigned hash() const { if (_hash == 0) _hash = computeHash(data(), len); return _hash; }
    119119            unsigned computedHash() const { ASSERT(_hash); return _hash; } // fast path for Identifiers
     120            void setHash(unsigned hash) { ASSERT(hash == computeHash(data(), len)); _hash = hash; } // fast path for Identifiers
    120121
    121122            static unsigned computeHash(const UChar*, int length);
     
    241242        UString(const char*, int length);
    242243        UString(const UChar*, int length);
    243         UString(UChar*, int length, bool copy);
     244        UString(const Vector<UChar>& buffer);
    244245
    245246        UString(const UString& s)
    246247            : m_rep(s.m_rep)
    247         {
    248         }
    249 
    250         UString(const Vector<UChar>& buffer);
    251 
    252         ~UString()
    253248        {
    254249        }
     
    259254        {
    260255        }
     256
     257        ~UString()
     258        {
     259        }
     260
     261        static UString createNonCopying(UChar* c, int length);
     262        static UString createFromUTF8(const char*);
    261263
    262264        static UString from(int);
     
    625627        adapter2.writeTo(result);
    626628
    627         return UString(buffer, length, false);
     629        return UString::createNonCopying(buffer, length);
    628630    }
    629631
     
    647649        adapter3.writeTo(result);
    648650
    649         return UString(buffer, length, false);
     651        return UString::createNonCopying(buffer, length);
    650652    }
    651653
     
    672674        adapter4.writeTo(result);
    673675
    674         return UString(buffer, length, false);
     676        return UString::createNonCopying(buffer, length);
    675677    }
    676678
     
    700702        adapter5.writeTo(result);
    701703
    702         return UString(buffer, length, false);
     704        return UString::createNonCopying(buffer, length);
    703705    }
    704706
     
    731733        adapter6.writeTo(result);
    732734
    733         return UString(buffer, length, false);
     735        return UString::createNonCopying(buffer, length);
    734736    }
    735737
     
    765767        adapter7.writeTo(result);
    766768
    767         return UString(buffer, length, false);
     769        return UString::createNonCopying(buffer, length);
    768770    }
    769771
     
    802804        adapter8.writeTo(result);
    803805
    804         return UString(buffer, length, false);
     806        return UString::createNonCopying(buffer, length);
    805807    }
    806808
Note: See TracChangeset for help on using the changeset viewer.