Ignore:
Timestamp:
May 19, 2015, 10:06:23 AM (10 years ago)
Author:
[email protected]
Message:

Give JSString a StringView getter and start using it.
<https://webkit.org/b/145131>

Reviewed by Anders Carlsson.

When JSString is a substring internally, calling value(ExecState*) on it
will reify the baseString/start/length tuple into a new StringImpl.

For clients that only want to look at the characters of a JSString, but
don't actually need a reffable StringImpl, adding a light-weight StringView
getter lets them avoid constructing anything.

This patch adds JSString::view(ExecState*) and uses it in a few places.
There are many more opportunities to use this API, but let's do a few things
at a time.

  • runtime/FunctionConstructor.cpp:

(JSC::constructFunctionSkippingEvalEnabledCheck):

  • runtime/JSGlobalObjectFunctions.cpp:

(JSC::decode):
(JSC::parseInt):
(JSC::jsToNumber):
(JSC::parseFloat):
(JSC::globalFuncParseInt):
(JSC::globalFuncParseFloat):
(JSC::globalFuncEscape):
(JSC::globalFuncUnescape):

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

(JSC::JSONProtoFuncParse):

  • runtime/JSString.cpp:

(JSC::JSString::getPrimitiveNumber):
(JSC::JSString::toNumber):

  • runtime/JSString.h:

(JSC::JSRopeString::view):
(JSC::JSString::view):

File:
1 edited

Legend:

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

    r182406 r184575  
    386386{
    387387    result = this;
    388     number = jsToNumber(value(exec));
     388    number = jsToNumber(view(exec));
    389389    return false;
    390390}
     
    397397double JSString::toNumber(ExecState* exec) const
    398398{
    399     return jsToNumber(value(exec));
     399    return jsToNumber(view(exec));
    400400}
    401401
Note: See TracChangeset for help on using the changeset viewer.