Ignore:
Timestamp:
Feb 15, 2010, 1:03:45 PM (15 years ago)
Author:
[email protected]
Message:

Bug 34952 - String lengths in UString should be unsigned.
This matches WebCore::StringImpl, and better unifies behaviour throughout JSC.

Reviewed by Geoff Garen.

JavaScriptCore:

  • JavaScriptCore.exp:
  • bytecode/EvalCodeCache.h:
  • runtime/Identifier.cpp:

(JSC::Identifier::equal):

  • runtime/Identifier.h:
  • runtime/JSGlobalObjectFunctions.cpp:

(JSC::globalFuncEscape):

  • runtime/JSONObject.cpp:

(JSC::gap):
(JSC::Stringifier::indent):

  • runtime/NumberPrototype.cpp:

(JSC::numberProtoFuncToFixed):
(JSC::numberProtoFuncToPrecision):

  • runtime/RegExp.cpp:

(JSC::RegExp::match):

  • runtime/StringPrototype.cpp:

(JSC::substituteBackreferencesSlow):
(JSC::stringProtoFuncReplace):
(JSC::stringProtoFuncSplit):
(JSC::trimString):

  • runtime/UString.cpp:

(JSC::UString::UString):
(JSC::UString::from):
(JSC::UString::getCString):
(JSC::UString::ascii):
(JSC::UString::operator[]):
(JSC::UString::toStrictUInt32):
(JSC::UString::find):
(JSC::UString::rfind):
(JSC::UString::substr):
(JSC::operator<):
(JSC::operator>):
(JSC::compare):
(JSC::equal):
(JSC::UString::UTF8String):

  • runtime/UString.h:

(JSC::UString::size):
(JSC::operator==):

  • runtime/UStringImpl.cpp:

(JSC::UStringImpl::create):

  • runtime/UStringImpl.h:

(JSC::UStringImpl::create):
(JSC::UStringImpl::size):
(JSC::UStringImpl::computeHash):
(JSC::UStringImpl::UStringImpl):

WebCore:

  • bindings/js/JSDOMWindowCustom.cpp:

(WebCore::JSDOMWindow::atob):
(WebCore::JSDOMWindow::btoa):

File:
1 edited

Legend:

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

    r54788 r54789  
    8383        UString();
    8484        UString(const char*); // Constructor for null-terminated string.
    85         UString(const char*, int length);
    86         UString(const UChar*, int length);
     85        UString(const char*, unsigned length);
     86        UString(const UChar*, unsigned length);
    8787        UString(const Vector<UChar>& buffer);
    8888
     
    137137        bool is8Bit() const;
    138138
    139         int size() const { return m_rep->size(); }
    140 
    141         UChar operator[](int pos) const;
     139        unsigned size() const { return m_rep->size(); }
     140
     141        UChar operator[](unsigned pos) const;
    142142
    143143        double toDouble(bool tolerateTrailingJunk, bool tolerateEmptyString) const;
     
    151151        unsigned toArrayIndex(bool* ok = 0) const;
    152152
    153         int find(const UString& f, int pos = 0) const;
    154         int find(UChar, int pos = 0) const;
    155         int rfind(const UString& f, int pos) const;
    156         int rfind(UChar, int pos) const;
    157 
    158         UString substr(int pos = 0, int len = -1) const;
     153        static const unsigned NotFound = 0xFFFFFFFFu;
     154        unsigned find(const UString& f, unsigned pos = 0) const;
     155        unsigned find(UChar, unsigned pos = 0) const;
     156        unsigned rfind(const UString& f, unsigned pos) const;
     157        unsigned rfind(UChar, unsigned pos) const;
     158
     159        UString substr(unsigned pos = 0, unsigned len = 0xFFFFFFFF) const;
    159160
    160161        static const UString& null() { return *s_nullUString; }
     
    182183    ALWAYS_INLINE bool operator==(const UString& s1, const UString& s2)
    183184    {
    184         int size = s1.size();
     185        unsigned size = s1.size();
    185186        switch (size) {
    186187        case 0:
     
    246247    // this runs too much risk of a tiny initial string holding down a
    247248    // huge buffer.
    248     // FIXME: this should be size_t but that would cause warnings until we
    249     // fix UString sizes to be size_t instead of int
    250     static const int minShareSize = Heap::minExtraCost / sizeof(UChar);
     249    static const unsigned minShareSize = Heap::minExtraCost / sizeof(UChar);
    251250
    252251    struct IdentifierRepHash : PtrHash<RefPtr<JSC::UString::Rep> > {
Note: See TracChangeset for help on using the changeset viewer.