Ignore:
Timestamp:
Aug 12, 2010, 6:05:10 PM (15 years ago)
Author:
[email protected]
Message:

Change UString constructors to match those in WTF::String.
This changes behaviour of UString((char*)0) to create null
strings, akin to UString() rather than UString::empty().
(This matches String). Remove unused constructors from
UString, and add null-terminated UTF-16 constructor, to
match String. Move String's constructor into the .cpp to
match UString.

Reviewed by Sam Weinig

(JSC::DebuggerCallFrame::calculatedFunctionName):

  • runtime/RegExpKey.h:

(JSC::RegExpKey::RegExpKey):

  • runtime/SmallStrings.cpp:

(JSC::SmallStrings::createSingleCharacterString):

  • runtime/UString.cpp:

(JSC::UString::UString):

  • runtime/UString.h:

(JSC::UString::UString):
(JSC::UString::swap):
(JSC::UString::adopt):
(JSC::UString::operator[]):

  • wtf/text/WTFString.h:

(WTF::String::String):
(WTF::String::adopt):
(WTF::String::operator[]):

File:
1 edited

Legend:

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

    r65266 r65286  
    5757COMPILE_ASSERT(sizeof(UString) == sizeof(void*), UString_should_stay_small);
    5858
    59 UString::UString(const char* c)
    60     : m_impl(StringImpl::create(c))
    61 {
    62 }
    63 
    64 UString::UString(const char* c, unsigned length)
    65     : m_impl(StringImpl::create(c, length))
    66 {
    67 }
    68 
    69 UString::UString(const UChar* c, unsigned length)
    70     : m_impl(StringImpl::create(c, length))
    71 {
    72 }
     59//    UString::UString(const UChar* characters, unsigned length)
     60//        : m_impl(characters ? StringImpl::create(characters, length) : 0)
     61//    {
     62//    }
     63UString::UString(const UChar* characters)
     64{
     65    if (!characters)
     66        return;
     67
     68    int length = 0;
     69    while (characters[length] != UChar(0))
     70        ++length;
     71
     72    m_impl = StringImpl::create(characters, length);
     73}
     74//    UString::UString(const char* characters)
     75//        : m_impl(characters ? StringImpl::create(characters) : 0)
     76//    {
     77//    }
     78//    UString::UString(const char* characters, unsigned length)
     79//        : m_impl(characters ? StringImpl::create(characters, length) : 0)
     80//    {
     81//    }
    7382
    7483UString UString::number(int i)
     
    209218
    210219    return asciiBuffer;
    211 }
    212 
    213 UChar UString::operator[](unsigned pos) const
    214 {
    215     if (pos >= length())
    216         return '\0';
    217     return characters()[pos];
    218220}
    219221
Note: See TracChangeset for help on using the changeset viewer.