Ignore:
Timestamp:
Dec 13, 2009, 4:27:07 PM (15 years ago)
Author:
[email protected]
Message:

https://bugs.webkit.org/show_bug.cgi?id=32496
Switch remaining cases of string construction to use StringBuilder.
Builds strings using a vector rather than using string append / addition.

Reviewed by Sam Weinig.

(JSC::FunctionExecutable::paramString):

  • runtime/FunctionConstructor.cpp:

(JSC::constructFunction):

  • runtime/JSGlobalObjectFunctions.cpp:

(JSC::encode):
(JSC::decode):
(JSC::globalFuncEscape):
(JSC::globalFuncUnescape):

  • runtime/JSONObject.cpp:

(JSC::Stringifier::stringify):
(JSC::Stringifier::indent):

  • runtime/JSString.h:
  • runtime/LiteralParser.cpp:

(JSC::LiteralParser::Lexer::lexString):

  • runtime/NumberPrototype.cpp:

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

  • runtime/Operations.h:

(JSC::jsString):

  • runtime/StringPrototype.cpp:

(JSC::substituteBackreferencesSlow):
(JSC::substituteBackreferences):
(JSC::stringProtoFuncConcat):

File:
1 edited

Legend:

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

    r51801 r52075  
    3333#include "LiteralParser.h"
    3434#include "PropertyNameArray.h"
     35#include "StringBuilder.h"
    3536#include <wtf/MathExtras.h>
    3637
     
    7172
    7273private:
    73     class StringBuilder : public Vector<UChar> {
    74     public:
    75         using Vector<UChar>::append;
    76 
    77         inline void append(const char* str)
    78         {
    79             size_t len = strlen(str);
    80             reserveCapacity(size() + len);
    81             for (size_t i = 0; i < len; i++)
    82                 Vector<UChar>::append(str[i]);
    83         }
    84 
    85         inline void append(const UString& str)
    86         {
    87             append(str.data(), str.size());
    88         }
    89     };
    90 
    9174    class Holder {
    9275    public:
     
    286269        return jsNull();
    287270
    288     result.shrinkToFit();
    289     size_t length = result.size();
    290     return jsString(m_exec, UString(result.releaseBuffer(), length, false));
     271    return jsString(m_exec, result.release());
    291272}
    292273
     
    478459    int newSize = m_indent.size() + m_gap.size();
    479460    if (newSize > m_repeatedGap.size())
    480         m_repeatedGap.append(m_gap);
     461        m_repeatedGap = makeString(m_repeatedGap, m_gap);
    481462    ASSERT(newSize <= m_repeatedGap.size());
    482463    m_indent = m_repeatedGap.substr(0, newSize);
Note: See TracChangeset for help on using the changeset viewer.