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/API/OpaqueJSString.cpp

    r165676 r165703  
    3030#include "Identifier.h"
    3131#include "JSGlobalObject.h"
     32#include <wtf/text/StringView.h>
    3233
    3334using namespace JSC;
     
    4849        return;
    4950
    50     if (!m_string.is8Bit() && m_string.deprecatedCharacters() == characters)
     51    if (!m_string.is8Bit() && m_string.characters16() == characters)
    5152        return;
    5253
     
    7172        return Identifier(Identifier::EmptyIdentifier);
    7273
    73     if (m_string.is8Bit())
    74         return Identifier(vm, m_string.characters8(), m_string.length());
    75 
    76     return Identifier(vm, m_string.characters16(), m_string.length());
     74    return Identifier(vm, m_string);
    7775}
    7876
     
    9290    unsigned length = m_string.length();
    9391    UChar* newCharacters = static_cast<UChar*>(fastMalloc(length * sizeof(UChar)));
    94 
    95     if (m_string.is8Bit()) {
    96         for (size_t i = 0; i < length; ++i)
    97             newCharacters[i] = m_string.characters8()[i];
    98     } else
    99         memcpy(newCharacters, m_string.characters16(), length * sizeof(UChar));
     92    StringView(m_string).getCharactersWithUpconvert(newCharacters);
    10093
    10194    if (!m_characters.compare_exchange_strong(characters, newCharacters)) {
Note: See TracChangeset for help on using the changeset viewer.