Ignore:
Timestamp:
Mar 16, 2014, 10:35:53 AM (11 years ago)
Author:
Darin Adler
Message:

Remove all uses of deprecatedCharacters from JavaScriptCore
https://bugs.webkit.org/show_bug.cgi?id=130304

Reviewed by Anders Carlsson.

Source/JavaScriptCore:

  • API/JSValueRef.cpp:

(JSValueMakeFromJSONString): Use characters16 in the 16-bit code path.

  • API/OpaqueJSString.cpp:

(OpaqueJSString::~OpaqueJSString): Use characters 16 in the 16-bit code path.
(OpaqueJSString::identifier): Get rid of custom Identifier constructor, and
juse use the standard one that takes a String.
(OpaqueJSString::characters): Use getCharactersWithUpconvert instead of a
hand-written alternative.

  • bindings/ScriptValue.cpp:

(Deprecated::jsToInspectorValue): Create InspectorString from String directly
instead of involving a character pointer. Use the String from Identifier
directly instead of making a new String.

  • inspector/ContentSearchUtilities.cpp:

(Inspector::ContentSearchUtilities::createSearchRegexSource): Use StringBuilder
instead of building a String a character at a time. This is still a very slow
way to do this. Also use strchr to search for a character instead of building
a String every time just to use find on it.

  • inspector/InspectorValues.cpp:

(Inspector::doubleQuoteString): Remove unnecessary trip through a
character pointer. This is still a really slow way to do this.
(Inspector::InspectorValue::parseJSON): Use StringView::upconvertedCharacters
instead of String::deprecatedCharacters. Still slow to always upconvert.

  • runtime/DateConstructor.cpp: Removed unneeded include.
  • runtime/DatePrototype.cpp: Ditto.
  • runtime/Identifier.h: Removed deprecatedCharacters function.
  • runtime/JSGlobalObjectFunctions.cpp:

(JSC::encode): Added a type cast to avoid ambiguity with the two character-
appending functions from JSStringBuilder. Removed unneeded code duplicating
what JSStringBuilder already does in its character append function.
(JSC::decode): Deleted code that creates a JSStringBuilder that is never used.
(JSC::parseIntOverflow): Changed lengths to unsigned. Made only the overload that
is used outside this file have external linkage. Added a new overload that takes
a StringView.
(JSC::parseInt): Use StringView::substring to call parseIntOverflow.
(JSC::globalFuncEscape): Use JSBuilder::append in a more efficient way for a
single character.

  • runtime/JSGlobalObjectFunctions.h: Removed unused overloads of parseIntOverflow.
  • runtime/JSStringBuilder.h: Marked this "lightly deprecated".

(JSC::JSStringBuilder::append): Overloaded for better speed with 8-bit characters.
Made one overload private. Fixed a performance bug where we would reserve capacity
in the 8-bit buffer but then append to the 16-bit buffer.

  • runtime/ObjectPrototype.cpp: Removed unneeded include.
  • runtime/StringPrototype.cpp:

(JSC::stringProtoFuncFontsize): Use StringView::getCharactersWithUpconvert.
(JSC::stringProtoFuncLink): Ditto.

Source/WTF:

  • wtf/dtoa.h:

(WTF::parseDouble): Added an overload that takes a StringView.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/Source/JavaScriptCore/runtime/JSGlobalObjectFunctions.cpp

    r163844 r165703  
    6464        char c = *p;
    6565        if (c && strchr(doNotEscape, c))
    66             builder.append(c);
     66            builder.append(static_cast<LChar>(c));
    6767        else {
    6868            char tmp[4];
     
    129129            }
    130130            if (charLen && (u == 0 || u >= 128 || !strchr(doNotUnescape, u))) {
    131                 if (u < 256)
    132                     builder.append(static_cast<LChar>(u));
    133                 else
    134                     builder.append(u);
     131                builder.append(u);
    135132                k += charLen;
    136133                continue;
     
    145142static JSValue decode(ExecState* exec, const char* doNotUnescape, bool strict)
    146143{
    147     JSStringBuilder builder;
    148144    String str = exec->argument(0).toString(exec)->value(exec);
    149145   
     
    190186}
    191187
    192 double parseIntOverflow(const LChar* s, int length, int radix)
     188double parseIntOverflow(const LChar* s, unsigned length, int radix)
    193189{
    194190    double number = 0.0;
     
    212208}
    213209
    214 double parseIntOverflow(const UChar* s, int length, int radix)
     210static double parseIntOverflow(const UChar* s, unsigned length, int radix)
    215211{
    216212    double number = 0.0;
     
    232228
    233229    return number;
     230}
     231
     232static double parseIntOverflow(StringView string, int radix)
     233{
     234    if (string.is8Bit())
     235        return parseIntOverflow(string.characters8(), string.length(), radix);
     236    return parseIntOverflow(string.characters16(), string.length(), radix);
    234237}
    235238
     
    309312        if (radix == 10) {
    310313            size_t parsedLength;
    311             number = parseDouble(s.deprecatedCharacters() + firstDigitPosition, p - firstDigitPosition, parsedLength);
     314            number = parseDouble(StringView(s).substring(firstDigitPosition, p - firstDigitPosition), parsedLength);
    312315        } else if (radix == 2 || radix == 4 || radix == 8 || radix == 16 || radix == 32)
    313             number = parseIntOverflow(s.substringSharingImpl(firstDigitPosition, p - firstDigitPosition).utf8().data(), p - firstDigitPosition, radix);
     316            number = parseIntOverflow(StringView(s).substring(firstDigitPosition, p - firstDigitPosition), radix);
    314317    }
    315318
     
    621624            int u = c[0];
    622625            if (u && strchr(do_not_escape, static_cast<char>(u)))
    623                 builder.append(c, 1);
     626                builder.append(*c);
    624627            else {
    625628                char tmp[4];
     
    640643            builder.append(tmp);
    641644        } else if (u != 0 && strchr(do_not_escape, static_cast<char>(u)))
    642             builder.append(c, 1);
     645            builder.append(*c);
    643646        else {
    644647            char tmp[4];
Note: See TracChangeset for help on using the changeset viewer.