⚠ Archived content — this site is no longer maintained.   Current WebKit documentation is at docs.webkit.org.

Changeset 249013 in webkit


Ignore:
Timestamp:
Aug 22, 2019, 9:26:04 AM (7 years ago)
Author:
Darin Adler
Message:

Use makeString and multi-argument StringBuilder::append instead of less efficient multiple appends
https://bugs.webkit.org/show_bug.cgi?id=200862

Reviewed by Ryosuke Niwa.

Source/JavaScriptCore:

  • runtime/ExceptionHelpers.cpp:

(JSC::createUndefinedVariableError): Got rid of unnecessary local variable.
(JSC::notAFunctionSourceAppender): Use single append instead of multiple.
Eliminate unneeded and unconventional use of makeString on a single string literal.
(JSC::invalidParameterInstanceofNotFunctionSourceAppender): Ditto.
(JSC::invalidParameterInstanceofhasInstanceValueNotFunctionSourceAppender): Ditto.
(JSC::createInvalidFunctionApplyParameterError): Ditto.
(JSC::createInvalidInParameterError): Ditto.
(JSC::createInvalidInstanceofParameterErrorNotFunction): Ditto.
(JSC::createInvalidInstanceofParameterErrorHasInstanceValueNotFunction): Ditto.

  • runtime/FunctionConstructor.cpp:

(JSC::constructFunctionSkippingEvalEnabledCheck): Use single append instead of multiple.

  • runtime/Options.cpp:

(JSC::Options::dumpOption): Ditto.

  • runtime/TypeProfiler.cpp:

(JSC::TypeProfiler::typeInformationForExpressionAtOffset): Ditto.

  • runtime/TypeSet.cpp:

(JSC::StructureShape::stringRepresentation): Ditto. Also use a modern for loop.

Source/WebCore:

  • Modules/indexeddb/shared/IDBDatabaseInfo.cpp:

(WebCore::IDBDatabaseInfo::loggingString const): Use one append instead of multiple.

  • Modules/indexeddb/shared/IDBObjectStoreInfo.cpp:

(WebCore::IDBObjectStoreInfo::loggingString const): Ditto.

  • Modules/mediastream/libwebrtc/LibWebRTCUtils.cpp:

(WebCore::toRTCCodecParameters): Ditto.

  • Modules/plugins/YouTubePluginReplacement.cpp:

(WebCore::YouTubePluginReplacement::youTubeURLFromAbsoluteURL): Ditto.

  • Modules/webdatabase/DatabaseTracker.cpp:

(WebCore::generateDatabaseFileName): Ditto.

  • Modules/websockets/WebSocketExtensionDispatcher.cpp:

(WebCore::WebSocketExtensionDispatcher::createHeaderValue const): Ditto.
(WebCore::WebSocketExtensionDispatcher::appendAcceptedExtension): Ditto.

  • Modules/websockets/WebSocketHandshake.cpp:

(WebCore::WebSocketHandshake::clientLocation const): Use makeString instead of
StringBuilder.

  • bindings/js/JSDOMExceptionHandling.cpp:

(WebCore::appendArgumentMustBe): Use one append instead of multiple.
(WebCore::throwArgumentMustBeEnumError): Ditto.
(WebCore::throwArgumentTypeError): Ditto.

  • contentextensions/CombinedURLFilters.cpp:

(WebCore::ContentExtensions::recursivePrint): Ditto.

  • css/CSSBasicShapes.cpp:

(WebCore::buildCircleString): Ditto.
(WebCore::buildEllipseString): Ditto.
(WebCore::buildPolygonString): Ditto.
(WebCore::buildInsetString): Ditto.

  • css/CSSCalculationValue.cpp:

(WebCore::buildCssText): Deleted.
(WebCore::CSSCalcValue::customCSSText const): Use makeString.

  • css/CSSComputedStyleDeclaration.cpp:

(WebCore::CSSComputedStyleDeclaration::cssText const): Use one append instead of multiple.

  • css/CSSCrossfadeValue.cpp:

(WebCore::CSSCrossfadeValue::customCSSText const): Use makeString.

  • css/CSSFilterImageValue.cpp:

(WebCore::CSSFilterImageValue::customCSSText const): Ditto.

  • css/CSSFontFaceRule.cpp:

(WebCore::CSSFontFaceRule::cssText const): Ditto.

  • css/CSSFontFaceSrcValue.cpp:

(WebCore::CSSFontFaceSrcValue::customCSSText const): Ditto.

  • css/CSSGradientValue.cpp:

(WebCore::appendGradientStops): Moved code here from CSSLinearGradientValue::customCSSText
so it can be shared with CSSRadialGradientValue::customCSSText. Use one append per stop.
(WebCore::CSSLinearGradientValue::customCSSText const): Use one append instead of multiple.
(WebCore::CSSRadialGradientValue::customCSSText const): Ditto.
(WebCore::CSSConicGradientValue::customCSSText const): Ditto.

  • css/CSSMediaRule.cpp:

(WebCore::CSSMediaRule::cssText const): Ditto.

  • css/CSSNamespaceRule.cpp:

(WebCore::CSSNamespaceRule::cssText const): Ditto.

  • css/CSSPageRule.cpp:

(WebCore::CSSPageRule::selectorText const): Use makeString.

  • css/CSSPrimitiveValue.cpp:

(WebCore::CSSPrimitiveValue::formatNumberForCustomCSSText const):
Use one append instead of multiple.

  • css/CSSPropertySourceData.cpp:

(WebCore::CSSPropertySourceData::CSSPropertySourceData): Initialize in the
structure definition instead of the constructor.
(WebCore::CSSPropertySourceData::toString const): Use makeString.

  • css/CSSPropertySourceData.h: Initialize in the structure definition.
  • css/CSSStyleRule.cpp:

(WebCore::CSSStyleRule::cssText const): Use makeString.

  • css/parser/CSSParser.cpp:

(WebCore::CSSParser::parseFontFaceDescriptor): Use makeString.

  • html/canvas/CanvasRenderingContext2D.cpp:

(WebCore::CanvasRenderingContext2D::font const): Use one append instead of multiple.

Source/WebKit:

  • Shared/mac/AuxiliaryProcessMac.mm:

(WebKit::setAndSerializeSandboxParameters): Use one append instead of multiple.

Source/WTF:

  • wtf/DateMath.cpp:

(WTF::makeRFC2822DateString): Use one append instead of multiple.

  • wtf/JSONValues.cpp:

(WTF::appendDoubleQuotedString): Ditto.

Tools:

  • WebKitTestRunner/InjectedBundle/TestRunner.cpp:

(WTR::TestRunner::statisticsDidRunTelemetryCallback): Use makeString.

  • WebKitTestRunner/TestController.cpp:

(WTR::TestController::findAndDumpWebKitProcessIdentifiers): Ditto.
(WTR::TestController::downloadDidReceiveServerRedirectToURL): Ditto.
(WTR::TestController::downloadDidFail): Ditto.

Location:
trunk
Files:
41 edited

Legend:

Unmodified
Added
Removed
  • trunk/Source/JavaScriptCore/ChangeLog

    r248989 r249013  
     12019-08-17  Darin Adler  <darin@apple.com>
     2
     3        Use makeString and multi-argument StringBuilder::append instead of less efficient multiple appends
     4        https://bugs.webkit.org/show_bug.cgi?id=200862
     5
     6        Reviewed by Ryosuke Niwa.
     7
     8        * runtime/ExceptionHelpers.cpp:
     9        (JSC::createUndefinedVariableError): Got rid of unnecessary local variable.
     10        (JSC::notAFunctionSourceAppender): Use single append instead of multiple.
     11        Eliminate unneeded and unconventional use of makeString on a single string literal.
     12        (JSC::invalidParameterInstanceofNotFunctionSourceAppender): Ditto.
     13        (JSC::invalidParameterInstanceofhasInstanceValueNotFunctionSourceAppender): Ditto.
     14        (JSC::createInvalidFunctionApplyParameterError): Ditto.
     15        (JSC::createInvalidInParameterError): Ditto.
     16        (JSC::createInvalidInstanceofParameterErrorNotFunction): Ditto.
     17        (JSC::createInvalidInstanceofParameterErrorHasInstanceValueNotFunction): Ditto.
     18
     19        * runtime/FunctionConstructor.cpp:
     20        (JSC::constructFunctionSkippingEvalEnabledCheck): Use single append instead of multiple.
     21        * runtime/Options.cpp:
     22        (JSC::Options::dumpOption): Ditto.
     23        * runtime/TypeProfiler.cpp:
     24        (JSC::TypeProfiler::typeInformationForExpressionAtOffset): Ditto.
     25        * runtime/TypeSet.cpp:
     26        (JSC::StructureShape::stringRepresentation): Ditto. Also use a modern for loop.
     27
    1282019-08-21  Mark Lam  <mark.lam@apple.com>
    229
  • trunk/Source/JavaScriptCore/runtime/ExceptionHelpers.cpp

    r248829 r249013  
    8282JSObject* createUndefinedVariableError(ExecState* exec, const Identifier& ident)
    8383{
    84     if (ident.isPrivateName()) {
    85         String message(makeString("Can't find private variable: PrivateSymbol.", ident.string()));
    86         return createReferenceError(exec, message);
    87     }
    88     String message(makeString("Can't find variable: ", ident.string()));
    89     return createReferenceError(exec, message);
     84    if (ident.isPrivateName())
     85        return createReferenceError(exec, makeString("Can't find private variable: PrivateSymbol.", ident.string()));
     86    return createReferenceError(exec, makeString("Can't find variable: ", ident.string()));
    9087}
    9188   
     
    204201        return defaultApproximateSourceError(originalMessage, sourceText);
    205202    StringBuilder builder(StringBuilder::OverflowHandler::RecordOverflow);
    206     builder.append(base);
    207     builder.appendLiteral(" is not a function. (In '");
    208     builder.append(sourceText);
    209     builder.appendLiteral("', '");
    210     builder.append(base);
    211     builder.appendLiteral("' is ");
     203    builder.append(base, " is not a function. (In '", sourceText, "', '", base, "' is ");
    212204    if (type == TypeSymbol)
    213205        builder.appendLiteral("a Symbol");
     
    220212
    221213    if (builder.hasOverflowed())
    222         return makeString("object is not a function."_s);
     214        return "object is not a function."_s;
    223215
    224216    return builder.toString();
     
    266258static String invalidParameterInstanceofNotFunctionSourceAppender(const String& originalMessage, const String& sourceText, RuntimeType runtimeType, ErrorInstance::SourceTextWhereErrorOccurred occurrence)
    267259{
    268     return invalidParameterInstanceofSourceAppender(WTF::makeString(" is not a function"), originalMessage, sourceText, runtimeType, occurrence);
     260    return invalidParameterInstanceofSourceAppender(" is not a function"_s, originalMessage, sourceText, runtimeType, occurrence);
    269261}
    270262
    271263static String invalidParameterInstanceofhasInstanceValueNotFunctionSourceAppender(const String& originalMessage, const String& sourceText, RuntimeType runtimeType, ErrorInstance::SourceTextWhereErrorOccurred occurrence)
    272264{
    273     return invalidParameterInstanceofSourceAppender(WTF::makeString("[Symbol.hasInstance] is not a function, undefined, or null"), originalMessage, sourceText, runtimeType, occurrence);
     265    return invalidParameterInstanceofSourceAppender("[Symbol.hasInstance] is not a function, undefined, or null"_s, originalMessage, sourceText, runtimeType, occurrence);
    274266}
    275267
     
    297289JSObject* createInvalidFunctionApplyParameterError(ExecState* exec, JSValue value)
    298290{
    299     VM& vm = exec->vm();
    300     JSObject* exception = createTypeError(exec, makeString("second argument to Function.prototype.apply must be an Array-like object"), defaultSourceAppender, runtimeTypeForValue(vm, value));
    301     ASSERT(exception->isErrorInstance());
    302     return exception;
     291    return createTypeError(exec, "second argument to Function.prototype.apply must be an Array-like object"_s, defaultSourceAppender, runtimeTypeForValue(exec->vm(), value));
    303292}
    304293
    305294JSObject* createInvalidInParameterError(ExecState* exec, JSValue value)
    306295{
    307     return createError(exec, value, makeString("is not an Object."), invalidParameterInSourceAppender);
     296    return createError(exec, value, "is not an Object."_s, invalidParameterInSourceAppender);
    308297}
    309298
    310299JSObject* createInvalidInstanceofParameterErrorNotFunction(ExecState* exec, JSValue value)
    311300{
    312     return createError(exec, value, makeString(" is not a function"), invalidParameterInstanceofNotFunctionSourceAppender);
     301    return createError(exec, value, " is not a function"_s, invalidParameterInstanceofNotFunctionSourceAppender);
    313302}
    314303
    315304JSObject* createInvalidInstanceofParameterErrorHasInstanceValueNotFunction(ExecState* exec, JSValue value)
    316305{
    317     return createError(exec, value, makeString("[Symbol.hasInstance] is not a function, undefined, or null"), invalidParameterInstanceofhasInstanceValueNotFunctionSourceAppender);
     306    return createError(exec, value, "[Symbol.hasInstance] is not a function, undefined, or null"_s, invalidParameterInstanceofhasInstanceValueNotFunctionSourceAppender);
    318307}
    319308
  • trunk/Source/JavaScriptCore/runtime/FunctionConstructor.cpp

    r246780 r249013  
    113113    } else {
    114114        StringBuilder builder(StringBuilder::OverflowHandler::RecordOverflow);
    115         builder.append(prefix);
    116         builder.append(functionName.string());
     115        builder.append(prefix, functionName.string(), '(');
    117116
    118         builder.append('(');
    119117        auto viewWithString = args.at(0).toString(exec)->viewWithUnderlyingString(exec);
    120118        RETURN_IF_EXCEPTION(scope, nullptr);
    121119        builder.append(viewWithString.view);
    122120        for (size_t i = 1; !builder.hasOverflowed() && i < args.size() - 1; i++) {
    123             builder.appendLiteral(", ");
    124121            auto viewWithString = args.at(i).toString(exec)->viewWithUnderlyingString(exec);
    125122            RETURN_IF_EXCEPTION(scope, nullptr);
    126             builder.append(viewWithString.view);
     123            builder.append(", ", viewWithString.view);
    127124        }
    128125        if (builder.hasOverflowed()) {
     
    132129
    133130        functionConstructorParametersEndPosition = builder.length() + 1;
    134         builder.appendLiteral(") {\n");
    135131
    136132        auto body = args.at(args.size() - 1).toString(exec)->viewWithUnderlyingString(exec);
    137133        RETURN_IF_EXCEPTION(scope, nullptr);
    138         builder.append(body.view);
    139         builder.appendLiteral("\n}");
     134        builder.append(") {\n", body.view, "\n}");
    140135        if (builder.hasOverflowed()) {
    141136            throwOutOfMemoryError(exec, scope);
  • trunk/Source/JavaScriptCore/runtime/Options.cpp

    r248143 r249013  
    867867    if (header)
    868868        builder.append(header);
    869     builder.append(option.name());
    870     builder.append('=');
     869    builder.append(option.name(), '=');
    871870    option.dump(builder);
    872871
     
    877876    }
    878877
    879     if (needsDescription) {
    880         builder.appendLiteral("   ... ");
    881         builder.append(option.description());
    882     }
     878    if (needsDescription)
     879        builder.append("   ... ", option.description());
    883880
    884881    builder.append(footer);
  • trunk/Source/JavaScriptCore/runtime/TypeProfiler.cpp

    r243467 r249013  
    9494    json.append(',');
    9595
    96     json.appendLiteral("\"instructionTypeSet\":");
    97     json.append(location->m_instructionTypeSet->toJSONString());
    98     json.append(',');
     96    json.append("\"instructionTypeSet\":", location->m_instructionTypeSet->toJSONString(), ',');
    9997
    10098    json.appendLiteral("\"isOverflown\":");
     
    105103
    106104    json.append('}');
    107    
     105
    108106    return json.toString();
    109107}
  • trunk/Source/JavaScriptCore/runtime/TypeSet.cpp

    r248898 r249013  
    413413    representation.append('{');
    414414    while (curShape) {
    415         for (auto it = curShape->m_fields.begin(), end = curShape->m_fields.end(); it != end; ++it) {
    416             String prop((*it).get());
    417             representation.append(prop);
    418             representation.appendLiteral(", ");
    419         }
    420 
    421         if (curShape->m_proto) {
    422             representation.appendLiteral("__proto__ [");
    423             representation.append(curShape->m_proto->m_constructorName);
    424             representation.appendLiteral("], ");
    425         }
    426 
     415        for (auto& field : curShape->m_fields)
     416            representation.append(StringView { field.get() }, ", ");
     417        if (curShape->m_proto)
     418            representation.append("__proto__ [", curShape->m_proto->m_constructorName, "], ");
    427419        curShape = curShape->m_proto;
    428420    }
  • trunk/Source/WTF/ChangeLog

    r248992 r249013  
     12019-08-17  Darin Adler  <darin@apple.com>
     2
     3        Use makeString and multi-argument StringBuilder::append instead of less efficient multiple appends
     4        https://bugs.webkit.org/show_bug.cgi?id=200862
     5
     6        Reviewed by Ryosuke Niwa.
     7
     8        * wtf/DateMath.cpp:
     9        (WTF::makeRFC2822DateString): Use one append instead of multiple.
     10        * wtf/JSONValues.cpp:
     11        (WTF::appendDoubleQuotedString): Ditto.
     12
    1132019-08-21  Mark Lam  <mark.lam@apple.com>
    214
  • trunk/Source/WTF/wtf/DateMath.cpp

    r239427 r249013  
    11711171{
    11721172    StringBuilder stringBuilder;
    1173     stringBuilder.append(weekdayName[dayOfWeek]);
    1174     stringBuilder.appendLiteral(", ");
    1175     stringBuilder.appendNumber(day);
    1176     stringBuilder.append(' ');
    1177     stringBuilder.append(monthName[month]);
    1178     stringBuilder.append(' ');
    1179     stringBuilder.appendNumber(year);
    1180     stringBuilder.append(' ');
     1173    stringBuilder.append(weekdayName[dayOfWeek], ", ", day, ' ', monthName[month], ' ', year, ' ');
    11811174
    11821175    appendTwoDigitNumber(stringBuilder, hours);
  • trunk/Source/WTF/wtf/JSONValues.cpp

    r246034 r249013  
    486486        // We could handle surrogates here if callers wanted that; for now we just
    487487        // write them out as a \u sequence, so a surrogate pair appears as two of them.
    488         builder.appendLiteral("\\u");
    489         builder.append(upperNibbleToASCIIHexDigit(codeUnit >> 8));
    490         builder.append(lowerNibbleToASCIIHexDigit(codeUnit >> 8));
    491         builder.append(upperNibbleToASCIIHexDigit(codeUnit));
    492         builder.append(lowerNibbleToASCIIHexDigit(codeUnit));
     488        builder.append("\\u",
     489            upperNibbleToASCIIHexDigit(codeUnit >> 8), lowerNibbleToASCIIHexDigit(codeUnit >> 8),
     490            upperNibbleToASCIIHexDigit(codeUnit), lowerNibbleToASCIIHexDigit(codeUnit));
    493491    }
    494492    builder.append('"');
  • trunk/Source/WebCore/ChangeLog

    r249007 r249013  
     12019-08-17  Darin Adler  <darin@apple.com>
     2
     3        Use makeString and multi-argument StringBuilder::append instead of less efficient multiple appends
     4        https://bugs.webkit.org/show_bug.cgi?id=200862
     5
     6        Reviewed by Ryosuke Niwa.
     7
     8        * Modules/indexeddb/shared/IDBDatabaseInfo.cpp:
     9        (WebCore::IDBDatabaseInfo::loggingString const): Use one append instead of multiple.
     10        * Modules/indexeddb/shared/IDBObjectStoreInfo.cpp:
     11        (WebCore::IDBObjectStoreInfo::loggingString const): Ditto.
     12        * Modules/mediastream/libwebrtc/LibWebRTCUtils.cpp:
     13        (WebCore::toRTCCodecParameters): Ditto.
     14        * Modules/plugins/YouTubePluginReplacement.cpp:
     15        (WebCore::YouTubePluginReplacement::youTubeURLFromAbsoluteURL): Ditto.
     16        * Modules/webdatabase/DatabaseTracker.cpp:
     17        (WebCore::generateDatabaseFileName): Ditto.
     18        * Modules/websockets/WebSocketExtensionDispatcher.cpp:
     19        (WebCore::WebSocketExtensionDispatcher::createHeaderValue const): Ditto.
     20        (WebCore::WebSocketExtensionDispatcher::appendAcceptedExtension): Ditto.
     21
     22        * Modules/websockets/WebSocketHandshake.cpp:
     23        (WebCore::WebSocketHandshake::clientLocation const): Use makeString instead of
     24        StringBuilder.
     25
     26        * bindings/js/JSDOMExceptionHandling.cpp:
     27        (WebCore::appendArgumentMustBe): Use one append instead of multiple.
     28        (WebCore::throwArgumentMustBeEnumError): Ditto.
     29        (WebCore::throwArgumentTypeError): Ditto.
     30        * contentextensions/CombinedURLFilters.cpp:
     31        (WebCore::ContentExtensions::recursivePrint): Ditto.
     32        * css/CSSBasicShapes.cpp:
     33        (WebCore::buildCircleString): Ditto.
     34        (WebCore::buildEllipseString): Ditto.
     35        (WebCore::buildPolygonString): Ditto.
     36        (WebCore::buildInsetString): Ditto.
     37
     38        * css/CSSCalculationValue.cpp:
     39        (WebCore::buildCssText): Deleted.
     40        (WebCore::CSSCalcValue::customCSSText const): Use makeString.
     41
     42        * css/CSSComputedStyleDeclaration.cpp:
     43        (WebCore::CSSComputedStyleDeclaration::cssText const): Use one append instead of multiple.
     44
     45        * css/CSSCrossfadeValue.cpp:
     46        (WebCore::CSSCrossfadeValue::customCSSText const): Use makeString.
     47        * css/CSSFilterImageValue.cpp:
     48        (WebCore::CSSFilterImageValue::customCSSText const): Ditto.
     49        * css/CSSFontFaceRule.cpp:
     50        (WebCore::CSSFontFaceRule::cssText const): Ditto.
     51        * css/CSSFontFaceSrcValue.cpp:
     52        (WebCore::CSSFontFaceSrcValue::customCSSText const): Ditto.
     53
     54        * css/CSSGradientValue.cpp:
     55        (WebCore::appendGradientStops): Moved code here from CSSLinearGradientValue::customCSSText
     56        so it can be shared with CSSRadialGradientValue::customCSSText. Use one append per stop.
     57        (WebCore::CSSLinearGradientValue::customCSSText const): Use one append instead of multiple.
     58        (WebCore::CSSRadialGradientValue::customCSSText const): Ditto.
     59        (WebCore::CSSConicGradientValue::customCSSText const): Ditto.
     60        * css/CSSMediaRule.cpp:
     61        (WebCore::CSSMediaRule::cssText const): Ditto.
     62        * css/CSSNamespaceRule.cpp:
     63        (WebCore::CSSNamespaceRule::cssText const): Ditto.
     64
     65        * css/CSSPageRule.cpp:
     66        (WebCore::CSSPageRule::selectorText const): Use makeString.
     67
     68        * css/CSSPrimitiveValue.cpp:
     69        (WebCore::CSSPrimitiveValue::formatNumberForCustomCSSText const):
     70        Use one append instead of multiple.
     71
     72        * css/CSSPropertySourceData.cpp:
     73        (WebCore::CSSPropertySourceData::CSSPropertySourceData): Initialize in the
     74        structure definition instead of the constructor.
     75        (WebCore::CSSPropertySourceData::toString const): Use makeString.
     76        * css/CSSPropertySourceData.h: Initialize in the structure definition.
     77
     78        * css/CSSStyleRule.cpp:
     79        (WebCore::CSSStyleRule::cssText const): Use makeString.
     80
     81        * css/parser/CSSParser.cpp:
     82        (WebCore::CSSParser::parseFontFaceDescriptor): Use makeString.
     83
     84        * html/canvas/CanvasRenderingContext2D.cpp:
     85        (WebCore::CanvasRenderingContext2D::font const): Use one append instead of multiple.
     86
    1872019-08-22  Kai Ninomiya  <kainino@chromium.org>
    288
  • trunk/Source/WebCore/Modules/indexeddb/shared/IDBDatabaseInfo.cpp

    r239427 r249013  
    157157
    158158#if !LOG_DISABLED
     159
    159160String IDBDatabaseInfo::loggingString() const
    160161{
    161162    StringBuilder builder;
    162     builder.appendLiteral("Database:");
    163     builder.append(m_name);
    164     builder.appendLiteral(" version ");
    165     builder.appendNumber(m_version);
    166     builder.append('\n');
    167     for (const auto& objectStore : m_objectStoreMap.values()) {
    168         builder.append(objectStore.loggingString(1));
    169         builder.append('\n');
    170     }
    171 
     163    builder.append("Database:", m_name, " version ", m_version, '\n');
     164    for (auto& objectStore : m_objectStoreMap.values())
     165        builder.append(objectStore.loggingString(1), '\n');
    172166    return builder.toString();
    173167}
     168
    174169#endif
    175170
  • trunk/Source/WebCore/Modules/indexeddb/shared/IDBObjectStoreInfo.cpp

    r240557 r249013  
    135135
    136136#if !LOG_DISABLED
     137
    137138String IDBObjectStoreInfo::loggingString(int indent) const
    138139{
     
    140141    for (int i = 0; i < indent; ++i)
    141142        builder.append(' ');
    142 
    143     builder.appendLiteral("Object store: ");
    144     builder.append(m_name);
    145     builder.appendNumber(m_identifier);
    146     for (auto index : m_indexMap.values()) {
    147         builder.append(index.loggingString(indent + 1));
    148         builder.append('\n');
    149     }
    150 
     143    builder.append("Object store: ", m_name, m_identifier);
     144    for (auto index : m_indexMap.values())
     145        builder.append(index.loggingString(indent + 1), '\n');
    151146    return builder.toString();
    152147}
  • trunk/Source/WebCore/Modules/mediastream/libwebrtc/LibWebRTCUtils.cpp

    r239532 r249013  
    105105
    106106    StringBuilder sdpFmtpLineBuilder;
    107     sdpFmtpLineBuilder.appendLiteral("a=fmtp:");
    108     sdpFmtpLineBuilder.appendNumber(parameters.payloadType);
    109     sdpFmtpLineBuilder.append(' ');
     107    sdpFmtpLineBuilder.append("a=fmtp:", parameters.payloadType, ' ');
    110108
    111109    bool isFirst = true;
     
    115113        else
    116114            isFirst = false;
    117 
    118         sdpFmtpLineBuilder.append(StringView { keyValue.first.c_str() });
    119         sdpFmtpLineBuilder.append('=');
    120         sdpFmtpLineBuilder.append(StringView { keyValue.second.c_str() });
     115        sdpFmtpLineBuilder.append(keyValue.first.c_str(), '=', keyValue.second.c_str());
    121116    }
    122117    parameters.sdpFmtpLine = sdpFmtpLineBuilder.toString();
  • trunk/Source/WebCore/Modules/plugins/YouTubePluginReplacement.cpp

    r246490 r249013  
    328328    else
    329329        finalURL.append(srcURLPrefix);
    330     finalURL.appendLiteral("/embed/");
    331     finalURL.append(videoID);
    332     if (!query.isEmpty()) {
    333         finalURL.append('?');
    334         finalURL.append(query);
    335     }
     330    finalURL.append("/embed/", videoID);
     331    if (!query.isEmpty())
     332        finalURL.append('?', query);
    336333    return finalURL.toString();
    337334}
  • trunk/Source/WebCore/Modules/webdatabase/DatabaseTracker.cpp

    r248846 r249013  
    309309static String generateDatabaseFileName()
    310310{
    311     StringBuilder stringBuilder;
    312 
    313     stringBuilder.append(createCanonicalUUIDString());
    314     stringBuilder.appendLiteral(".db");
    315 
    316     return stringBuilder.toString();
     311    return makeString(createCanonicalUUIDString(), ".db");
    317312}
    318313
  • trunk/Source/WebCore/Modules/websockets/WebSocketExtensionDispatcher.cpp

    r220250 r249013  
    6565    StringBuilder builder;
    6666    builder.append(m_processors[0]->handshakeString());
    67     for (size_t i = 1; i < numProcessors; ++i) {
    68         builder.appendLiteral(", ");
    69         builder.append(m_processors[i]->handshakeString());
    70     }
     67    for (size_t i = 1; i < numProcessors; ++i)
     68        builder.append(", ", m_processors[i]->handshakeString());
    7169    return builder.toString();
    7270}
     
    7977    // FIXME: Should use ListHashSet to keep the order of the parameters.
    8078    for (auto& parameter : extensionParameters) {
    81         m_acceptedExtensionsBuilder.appendLiteral("; ");
    82         m_acceptedExtensionsBuilder.append(parameter.key);
    83         if (!parameter.value.isNull()) {
    84             m_acceptedExtensionsBuilder.append('=');
    85             m_acceptedExtensionsBuilder.append(parameter.value);
    86         }
     79        m_acceptedExtensionsBuilder.append("; ", parameter.key);
     80        if (!parameter.value.isNull())
     81            m_acceptedExtensionsBuilder.append('=', parameter.value);
    8782    }
    8883}
  • trunk/Source/WebCore/Modules/websockets/WebSocketHandshake.cpp

    r244391 r249013  
    167167String WebSocketHandshake::clientLocation() const
    168168{
    169     StringBuilder builder;
    170     builder.append(m_secure ? "wss" : "ws");
    171     builder.appendLiteral("://");
    172     builder.append(hostName(m_url, m_secure));
    173     builder.append(resourceName(m_url));
    174     return builder.toString();
     169    return makeString(m_secure ? "wss" : "ws", "://", hostName(m_url, m_secure), resourceName(m_url));
    175170}
    176171
  • trunk/Source/WebCore/bindings/js/JSDOMExceptionHandling.cpp

    r244312 r249013  
    171171static void appendArgumentMustBe(StringBuilder& builder, unsigned argumentIndex, const char* argumentName, const char* interfaceName, const char* functionName)
    172172{
    173     builder.appendLiteral("Argument ");
    174     builder.appendNumber(argumentIndex + 1);
    175     builder.appendLiteral(" ('");
    176     builder.append(argumentName);
    177     builder.appendLiteral("') to ");
    178     if (!functionName) {
    179         builder.appendLiteral("the ");
    180         builder.append(interfaceName);
    181         builder.appendLiteral(" constructor");
    182     } else {
    183         builder.append(interfaceName);
    184         builder.append('.');
    185         builder.append(functionName);
    186     }
     173    builder.append("Argument ", argumentIndex + 1, " ('", argumentName, "') to ");
     174    if (!functionName)
     175        builder.append("the ", interfaceName, " constructor");
     176    else
     177        builder.append(interfaceName, '.', functionName);
    187178    builder.appendLiteral(" must be ");
    188179}
     
    210201    StringBuilder builder;
    211202    appendArgumentMustBe(builder, argumentIndex, argumentName, functionInterfaceName, functionName);
    212     builder.appendLiteral("one of: ");
    213     builder.append(expectedValues);
     203    builder.append("one of: ", expectedValues);
    214204    return throwVMTypeError(&state, scope, builder.toString());
    215205}
     
    227217    StringBuilder builder;
    228218    appendArgumentMustBe(builder, argumentIndex, argumentName, functionInterfaceName, functionName);
    229     builder.appendLiteral("an instance of ");
    230     builder.append(expectedType);
     219    builder.append("an instance of ", expectedType);
    231220    return throwVMTypeError(&state, scope, builder.toString());
    232221}
  • trunk/Source/WebCore/contentextensions/CombinedURLFilters.cpp

    r248846 r249013  
    120120        for (unsigned i = 0; i < depth * 2; ++i)
    121121            builder.append(' ');
    122         builder.appendLiteral("vertex edge: ");
    123         builder.append(edge.term->toString());
    124         builder.append('\n');
     122        builder.append("vertex edge: ", edge.term->toString(), '\n');
    125123        dataLogF("%s", builder.toString().utf8().data());
    126124        ASSERT(edge.child);
  • trunk/Source/WebCore/css/CSSBasicShapes.cpp

    r240641 r249013  
    8787static String buildCircleString(const String& radius, const String& centerX, const String& centerY)
    8888{
    89     char opening[] = "circle(";
    90     char at[] = "at";
    91     char separator[] = " ";
    9289    StringBuilder result;
    93     result.appendLiteral(opening);
     90    result.appendLiteral("circle(");
    9491    if (!radius.isNull())
    9592        result.append(radius);
    96 
    9793    if (!centerX.isNull() || !centerY.isNull()) {
    9894        if (!radius.isNull())
    99             result.appendLiteral(separator);
    100         result.appendLiteral(at);
    101         result.appendLiteral(separator);
    102         result.append(centerX);
    103         result.appendLiteral(separator);
    104         result.append(centerY);
    105     }
    106     result.appendLiteral(")");
     95            result.append(' ');
     96        result.append("at ", centerX, ' ', centerY);
     97    }
     98    result.append(')');
    10799    return result.toString();
    108100}
     
    135127static String buildEllipseString(const String& radiusX, const String& radiusY, const String& centerX, const String& centerY)
    136128{
    137     char opening[] = "ellipse(";
    138     char at[] = "at";
    139     char separator[] = " ";
    140129    StringBuilder result;
    141     result.appendLiteral(opening);
     130    result.appendLiteral("ellipse(");
    142131    bool needsSeparator = false;
    143132    if (!radiusX.isNull()) {
     
    147136    if (!radiusY.isNull()) {
    148137        if (needsSeparator)
    149             result.appendLiteral(separator);
     138            result.append(' ');
    150139        result.append(radiusY);
    151140        needsSeparator = true;
    152141    }
    153 
    154142    if (!centerX.isNull() || !centerY.isNull()) {
    155143        if (needsSeparator)
    156             result.appendLiteral(separator);
    157         result.appendLiteral(at);
    158         result.appendLiteral(separator);
    159         result.append(centerX);
    160         result.appendLiteral(separator);
    161         result.append(centerY);
    162     }
    163     result.appendLiteral(")");
     144            result.append(' ');
     145        result.append("at ", centerX, ' ', centerY);
     146    }
     147    result.append(')');
    164148    return result.toString();
    165149}
     
    271255        if (i)
    272256            result.appendLiteral(commaSeparator);
    273         result.append(points[i]);
    274         result.append(' ');
    275         result.append(points[i + 1]);
     257        result.append(points[i], ' ', points[i + 1]);
    276258    }
    277259
     
    323305    const String& bottomLeftRadiusWidth, const String& bottomLeftRadiusHeight)
    324306{
    325     char opening[] = "inset(";
    326     char separator[] = " ";
    327     char cornersSeparator[] = "round";
    328307    StringBuilder result;
    329     result.appendLiteral(opening);
    330     result.append(top);
     308    result.append("inset(", top);
    331309
    332310    bool showLeftArg = !left.isNull() && left != right;
    333311    bool showBottomArg = !bottom.isNull() && (bottom != top || showLeftArg);
    334312    bool showRightArg = !right.isNull() && (right != top || showBottomArg);
    335     if (showRightArg) {
    336         result.appendLiteral(separator);
    337         result.append(right);
    338     }
    339     if (showBottomArg) {
    340         result.appendLiteral(separator);
    341         result.append(bottom);
    342     }
    343     if (showLeftArg) {
    344         result.appendLiteral(separator);
    345         result.append(left);
    346     }
     313    if (showRightArg)
     314        result.append(' ', right);
     315    if (showBottomArg)
     316        result.append(' ', bottom);
     317    if (showLeftArg)
     318        result.append(' ', left);
    347319
    348320    if (!topLeftRadiusWidth.isNull() && !topLeftRadiusHeight.isNull()) {
     
    354326
    355327        if (!areDefaultCornerRadii) {
    356             result.appendLiteral(separator);
    357             result.appendLiteral(cornersSeparator);
    358 
    359             for (size_t i = 0; i < horizontalRadii.size(); ++i) {
    360                 result.appendLiteral(separator);
    361                 result.append(horizontalRadii[i]);
    362             }
     328            result.appendLiteral(" round");
     329
     330            for (auto& radius : horizontalRadii)
     331                result.append(' ', radius);
    363332
    364333            if (verticalRadii.size() != horizontalRadii.size()
    365334                || !WTF::VectorComparer<false, String>::compare(verticalRadii.data(), horizontalRadii.data(), verticalRadii.size())) {
    366                 result.appendLiteral(separator);
    367                 result.appendLiteral("/");
    368 
    369                 for (size_t i = 0; i < verticalRadii.size(); ++i) {
    370                     result.appendLiteral(separator);
    371                     result.append(verticalRadii[i]);
    372                 }
     335                result.appendLiteral(" /");
     336                for (auto& radius : verticalRadii)
     337                    result.append(' ', radius);
    373338            }
    374339        }
  • trunk/Source/WebCore/css/CSSCalculationValue.cpp

    r248846 r249013  
    150150}
    151151
    152 static String buildCssText(const String& expression)
    153 {
    154     StringBuilder result;
    155     result.appendLiteral("calc");
    156     bool expressionHasSingleTerm = expression[0] != '(';
    157     if (expressionHasSingleTerm)
    158         result.append('(');
    159     result.append(expression);
    160     if (expressionHasSingleTerm)
    161         result.append(')');
    162     return result.toString();
    163 }
    164 
    165152String CSSCalcValue::customCSSText() const
    166153{
    167     return buildCssText(m_expression->customCSSText());
     154    auto expression = m_expression->customCSSText();
     155    if (expression[0] == '(')
     156        return makeString("calc", expression);
     157    return makeString("calc(", expression, ')');
    168158}
    169159
  • trunk/Source/WebCore/css/CSSComputedStyleDeclaration.cpp

    r247388 r249013  
    16921692{
    16931693    StringBuilder result;
    1694 
    16951694    for (unsigned i = 0; i < numComputedProperties; i++) {
    16961695        if (i)
    16971696            result.append(' ');
    1698         result.append(getPropertyName(computedProperties[i]));
    1699         result.appendLiteral(": ");
    1700         result.append(getPropertyValue(computedProperties[i]));
    1701         result.append(';');
    1702     }
    1703 
     1697        result.append(getPropertyName(computedProperties[i]), ": ", getPropertyValue(computedProperties[i]), ';');
     1698    }
    17041699    return result.toString();
    17051700}
  • trunk/Source/WebCore/css/CSSCrossfadeValue.cpp

    r231105 r249013  
    9292String CSSCrossfadeValue::customCSSText() const
    9393{
    94     StringBuilder result;
    95     if (m_isPrefixed)
    96         result.appendLiteral("-webkit-cross-fade(");
    97     else
    98         result.appendLiteral("cross-fade(");
    99     result.append(m_fromValue->cssText());
    100     result.appendLiteral(", ");
    101     result.append(m_toValue->cssText());
    102     result.appendLiteral(", ");
    103     result.append(m_percentageValue->cssText());
    104     result.append(')');
    105     return result.toString();
     94    return makeString(m_isPrefixed ? "-webkit-" : "", "cross-fade(", m_fromValue->cssText(), ", ", m_toValue->cssText(), ", ", m_percentageValue->cssText(), ')');
    10695}
    10796
  • trunk/Source/WebCore/css/CSSFilterImageValue.cpp

    r235630 r249013  
    4848String CSSFilterImageValue::customCSSText() const
    4949{
    50     StringBuilder result;
    51     result.appendLiteral("filter(");
    52     result.append(m_imageValue->cssText());
    53     result.appendLiteral(", ");
    54     result.append(m_filterValue->cssText());
    55     result.append(')');
    56     return result.toString();
     50    return makeString("filter(", m_imageValue->cssText(), ", ", m_filterValue->cssText(), ')');
    5751}
    5852
  • trunk/Source/WebCore/css/CSSFontFaceRule.cpp

    r177228 r249013  
    5151String CSSFontFaceRule::cssText() const
    5252{
    53     StringBuilder result;
    54     result.appendLiteral("@font-face { ");
    55     String descs = m_fontFaceRule->properties().asText();
    56     result.append(descs);
    57     if (!descs.isEmpty())
    58         result.append(' ');
    59     result.append('}');
    60     return result.toString();
     53    String declarations = m_fontFaceRule->properties().asText();
     54    if (declarations.isEmpty())
     55        return "@font-face { }"_s;
     56    return makeString("@font-face { ", declarations, " }");
    6157}
    6258
  • trunk/Source/WebCore/css/CSSFontFaceSrcValue.cpp

    r238698 r249013  
    7070String CSSFontFaceSrcValue::customCSSText() const
    7171{
    72     StringBuilder result;
    73     if (isLocal())
    74         result.appendLiteral("local(");
    75     else
    76         result.appendLiteral("url(");
    77     result.append(m_resource);
    78     result.append(')');
    79     if (!m_format.isEmpty()) {
    80         result.appendLiteral(" format(");
    81         result.append(m_format);
    82         result.append(')');
    83     }
    84     return result.toString();
     72    const char* prefix = isLocal() ? "local(" : "url(";
     73    if (m_format.isEmpty())
     74        return makeString(prefix, m_resource, ')');
     75    return makeString(prefix, m_resource, ')', " format(", m_format, ')');
    8576}
    8677
  • trunk/Source/WebCore/css/CSSGradientValue.cpp

    r243163 r249013  
    11/*
    2  * Copyright (C) 2008 Apple Inc.  All rights reserved.
     2 * Copyright (C) 2008 Apple Inc. All rights reserved.
    33 *
    44 * Redistribution and use in source and binary forms, with or without
     
    231231class ConicGradientAdapter {
    232232public:
    233     explicit ConicGradientAdapter() { }
    234233    float gradientLength() const { return 1; }
    235234    float maxExtent(float, float) const { return 1; }
     
    668667}
    669668
     669static void appendGradientStops(StringBuilder& builder, const Vector<CSSGradientColorStop, 2>& stops)
     670{
     671    for (auto& stop : stops) {
     672        double position = stop.m_position->doubleValue(CSSPrimitiveValue::CSS_NUMBER);
     673        if (!position)
     674            builder.append(", from(", stop.m_color->cssText(), ')');
     675        else if (position == 1)
     676            builder.append(", to(", stop.m_color->cssText(), ')');
     677        else
     678            builder.append(", color-stop(", FormattedNumber::fixedPrecision(position), ", ", stop.m_color->cssText(), ')');
     679    }
     680}
     681
    670682String CSSLinearGradientValue::customCSSText() const
    671683{
    672684    StringBuilder result;
    673685    if (m_gradientType == CSSDeprecatedLinearGradient) {
    674         result.appendLiteral("-webkit-gradient(linear, ");
    675         result.append(m_firstX->cssText());
    676         result.append(' ');
    677         result.append(m_firstY->cssText());
    678         result.appendLiteral(", ");
    679         result.append(m_secondX->cssText());
    680         result.append(' ');
    681         result.append(m_secondY->cssText());
    682 
    683         for (auto& stop : m_stops) {
    684             result.appendLiteral(", ");
    685             auto position = stop.m_position->doubleValue(CSSPrimitiveValue::CSS_NUMBER);
    686             if (!position) {
    687                 result.appendLiteral("from(");
    688                 result.append(stop.m_color->cssText());
    689                 result.append(')');
    690             } else if (position == 1) {
    691                 result.appendLiteral("to(");
    692                 result.append(stop.m_color->cssText());
    693                 result.append(')');
    694             } else {
    695                 result.appendLiteral("color-stop(");
    696                 result.appendFixedPrecisionNumber(position);
    697                 result.appendLiteral(", ");
    698                 result.append(stop.m_color->cssText());
    699                 result.append(')');
    700             }
    701         }
     686        result.append("-webkit-gradient(linear, ", m_firstX->cssText(), ' ', m_firstY->cssText(), ", ", m_secondX->cssText(), ' ', m_secondY->cssText());
     687        appendGradientStops(result, m_stops);
    702688    } else if (m_gradientType == CSSPrefixedLinearGradient) {
    703689        if (m_repeating)
     
    709695            result.append(m_angle->cssText());
    710696        else {
    711             if (m_firstX && m_firstY) {
     697            if (m_firstX && m_firstY)
     698                result.append(m_firstX->cssText(), ' ', m_firstY->cssText());
     699            else if (m_firstX)
    712700                result.append(m_firstX->cssText());
    713                 result.append(' ');
     701            else if (m_firstY)
    714702                result.append(m_firstY->cssText());
    715             } else if (m_firstX || m_firstY) {
    716                 if (m_firstX)
    717                     result.append(m_firstX->cssText());
    718 
    719                 if (m_firstY)
    720                     result.append(m_firstY->cssText());
    721             }
    722         }
    723 
    724         for (unsigned i = 0; i < m_stops.size(); i++) {
    725             auto& stop = m_stops[i];
    726             result.appendLiteral(", ");
    727             result.append(stop.m_color->cssText());
    728             if (stop.m_position) {
    729                 result.append(' ');
    730                 result.append(stop.m_position->cssText());
    731             }
     703        }
     704
     705        for (auto& stop : m_stops) {
     706            result.append(", ", stop.m_color->cssText());
     707            if (stop.m_position)
     708                result.append(' ', stop.m_position->cssText());
    732709        }
    733710    } else {
     
    744721        } else if ((m_firstX || m_firstY) && !(!m_firstX && m_firstY && m_firstY->valueID() == CSSValueBottom)) {
    745722            result.appendLiteral("to ");
    746             if (m_firstX && m_firstY) {
    747                 result.append(m_firstX->cssText());
    748                 result.append(' ');
    749                 result.append(m_firstY->cssText());
    750             } else if (m_firstX)
     723            if (m_firstX && m_firstY)
     724                result.append(m_firstX->cssText(), ' ', m_firstY->cssText());
     725            else if (m_firstX)
    751726                result.append(m_firstX->cssText());
    752727            else
     
    758733            result.appendLiteral(", ");
    759734
    760         for (unsigned i = 0; i < m_stops.size(); i++) {
    761             const CSSGradientColorStop& stop = m_stops[i];
    762             if (i)
     735        bool wroteFirstStop = false;
     736        for (auto& stop : m_stops) {
     737            if (wroteFirstStop)
    763738                result.appendLiteral(", ");
     739            wroteFirstStop = true;
    764740            if (!stop.isMidpoint)
    765741                result.append(stop.m_color->cssText());
     
    770746            }
    771747        }
    772        
    773748    }
    774749
     
    948923
    949924    if (m_gradientType == CSSDeprecatedRadialGradient) {
    950         result.appendLiteral("-webkit-gradient(radial, ");
    951         result.append(m_firstX->cssText());
    952         result.append(' ');
    953         result.append(m_firstY->cssText());
    954         result.appendLiteral(", ");
    955         result.append(m_firstRadius->cssText());
    956         result.appendLiteral(", ");
    957         result.append(m_secondX->cssText());
    958         result.append(' ');
    959         result.append(m_secondY->cssText());
    960         result.appendLiteral(", ");
    961         result.append(m_secondRadius->cssText());
    962 
    963         // FIXME: share?
    964         for (auto& stop : m_stops) {
    965             result.appendLiteral(", ");
    966             auto position = stop.m_position->doubleValue(CSSPrimitiveValue::CSS_NUMBER);
    967             if (!position) {
    968                 result.appendLiteral("from(");
    969                 result.append(stop.m_color->cssText());
    970                 result.append(')');
    971             } else if (position == 1) {
    972                 result.appendLiteral("to(");
    973                 result.append(stop.m_color->cssText());
    974                 result.append(')');
    975             } else {
    976                 result.appendLiteral("color-stop(");
    977                 result.appendFixedPrecisionNumber(position);
    978                 result.appendLiteral(", ");
    979                 result.append(stop.m_color->cssText());
    980                 result.append(')');
    981             }
    982         }
     925        result.append("-webkit-gradient(radial, ", m_firstX->cssText(), ' ', m_firstY->cssText(), ", ", m_firstRadius->cssText(),
     926            ", ", m_secondX->cssText(), ' ', m_secondY->cssText(), ", ", m_secondRadius->cssText());
     927        appendGradientStops(result, m_stops);
    983928    } else if (m_gradientType == CSSPrefixedRadialGradient) {
    984929        if (m_repeating)
     
    987932            result.appendLiteral("-webkit-radial-gradient(");
    988933
    989         if (m_firstX && m_firstY) {
     934        if (m_firstX && m_firstY)
     935            result.append(m_firstX->cssText(), ' ', m_firstY->cssText());
     936        else if (m_firstX)
    990937            result.append(m_firstX->cssText());
    991             result.append(' ');
    992             result.append(m_firstY->cssText());
    993         } else if (m_firstX)
    994             result.append(m_firstX->cssText());
    995          else if (m_firstY)
     938        else if (m_firstY)
    996939            result.append(m_firstY->cssText());
    997940        else
     
    1000943        if (m_shape || m_sizingBehavior) {
    1001944            result.appendLiteral(", ");
    1002             if (m_shape) {
    1003                 result.append(m_shape->cssText());
    1004                 result.append(' ');
    1005             } else
     945            if (m_shape)
     946                result.append(m_shape->cssText(), ' ');
     947            else
    1006948                result.appendLiteral("ellipse ");
    1007 
    1008949            if (m_sizingBehavior)
    1009950                result.append(m_sizingBehavior->cssText());
    1010951            else
    1011952                result.appendLiteral("cover");
    1012 
    1013         } else if (m_endHorizontalSize && m_endVerticalSize) {
    1014             result.appendLiteral(", ");
    1015             result.append(m_endHorizontalSize->cssText());
    1016             result.append(' ');
    1017             result.append(m_endVerticalSize->cssText());
    1018         }
    1019 
    1020         for (unsigned i = 0; i < m_stops.size(); i++) {
    1021             const CSSGradientColorStop& stop = m_stops[i];
    1022             result.appendLiteral(", ");
    1023             result.append(stop.m_color->cssText());
    1024             if (stop.m_position) {
    1025                 result.append(' ');
    1026                 result.append(stop.m_position->cssText());
    1027             }
     953        } else if (m_endHorizontalSize && m_endVerticalSize)
     954            result.append(", ", m_endHorizontalSize->cssText(), ' ', m_endVerticalSize->cssText());
     955
     956        for (auto& stop : m_stops) {
     957            result.append(", ", stop.m_color->cssText());
     958            if (stop.m_position)
     959                result.append(' ', stop.m_position->cssText());
    1028960        }
    1029961    } else {
     
    1051983                result.append(' ');
    1052984            result.append(m_endHorizontalSize->cssText());
    1053             if (m_endVerticalSize) {
    1054                 result.append(' ');
    1055                 result.append(m_endVerticalSize->cssText());
    1056             }
     985            if (m_endVerticalSize)
     986                result.append(' ', m_endVerticalSize->cssText());
    1057987            wroteSomething = true;
    1058988        }
     
    1062992                result.append(' ');
    1063993            result.appendLiteral("at ");
    1064             if (m_firstX && m_firstY) {
    1065                 result.append(m_firstX->cssText());
    1066                 result.append(' ');
    1067                 result.append(m_firstY->cssText());
    1068             } else if (m_firstX)
     994            if (m_firstX && m_firstY)
     995                result.append(m_firstX->cssText(), ' ', m_firstY->cssText());
     996            else if (m_firstX)
    1069997                result.append(m_firstX->cssText());
    1070998            else
     
    10981026{
    10991027    float result = 0;
    1100     if (radius.isNumber()) // Can the radius be a percentage?
     1028    if (radius.isNumber())
    11011029        result = radius.floatValue() * conversionData.zoom();
    11021030    else if (widthOrHeight && radius.isPercentage())
     
    11041032    else
    11051033        result = radius.computeLength<float>(conversionData);
    1106 
    11071034    return result;
    11081035}
     
    13871314
    13881315    if (m_angle) {
    1389         result.appendLiteral("from ");
    1390         result.append(m_angle->cssText());
     1316        result.append("from ", m_angle->cssText());
    13911317        wroteSomething = true;
    13921318    }
     
    13941320    if (m_firstX && m_firstY) {
    13951321        if (wroteSomething)
    1396             result.appendLiteral(" ");
    1397         result.appendLiteral("at ");
    1398         result.append(m_firstX->cssText());
    1399         result.append(' ');
    1400         result.append(m_firstY->cssText());
     1322            result.append(' ');
     1323        result.append("at ", m_firstX->cssText(), ' ', m_firstY->cssText());
    14011324        wroteSomething = true;
    14021325    }
  • trunk/Source/WebCore/css/CSSMediaRule.cpp

    r218890 r249013  
    5252    result.appendLiteral("@media ");
    5353    if (mediaQueries()) {
    54         result.append(mediaQueries()->mediaText());
    55         result.append(' ');
     54        result.append(mediaQueries()->mediaText(), ' ');
    5655    }
    5756    result.appendLiteral("{ \n");
  • trunk/Source/WebCore/css/CSSNamespaceRule.cpp

    r246490 r249013  
    5858    if (!prefix().isEmpty())
    5959        result.append(' ');
    60     result.append("url(");
    61     result.append(serializeString(namespaceURI()));
    62     result.append(");");
     60    result.append("url(", serializeString(namespaceURI()), ");");
    6361    return result.toString();
    6462}
  • trunk/Source/WebCore/css/CSSPageRule.cpp

    r234825 r249013  
    5555String CSSPageRule::selectorText() const
    5656{
    57     StringBuilder text;
    58     text.appendLiteral("@page");
    59     const CSSSelector* selector = m_pageRule->selector();
    60     if (selector) {
     57    if (auto* selector = m_pageRule->selector()) {
    6158        String pageSpecification = selector->selectorText();
    62         if (!pageSpecification.isEmpty() && pageSpecification != starAtom()) {
    63             text.append(' ');
    64             text.append(pageSpecification);
    65         }
     59        if (!pageSpecification.isEmpty() && pageSpecification != starAtom())
     60            return makeString("@page ", pageSpecification);
    6661    }
    67     return text.toString();
     62    return "@page"_s;
    6863}
    6964
  • trunk/Source/WebCore/css/CSSPrimitiveValue.cpp

    r246490 r249013  
    10041004        }
    10051005        String listStyle = m_value.counter->listStyle();
    1006         if (!listStyle.isEmpty()) {
    1007             result.appendLiteral(", ");
    1008             result.append(listStyle);
    1009         }
     1006        if (!listStyle.isEmpty())
     1007            result.append(", ", listStyle);
    10101008        result.append(')');
    10111009
  • trunk/Source/WebCore/css/CSSPropertySourceData.cpp

    r218890 r249013  
    7878    : name(emptyString())
    7979    , value(emptyString())
    80     , important(false)
    81     , disabled(false)
    82     , parsedOk(false)
    83     , range(SourceRange(0, 0))
    8480{
    8581}
     
    8985    if (!name && value == "e")
    9086        return String();
    91 
    92     StringBuilder result;
    93     result.append(name);
    94     result.appendLiteral(": ");
    95     result.append(value);
    96     if (important)
    97         result.appendLiteral(" !important");
    98     result.append(';');
    99     return result.toString();
     87    return makeString(name, ": ", value, important ? " !important" : "", ';');
    10088}
    10189
  • trunk/Source/WebCore/css/CSSPropertySourceData.h

    r218588 r249013  
    6161    String name;
    6262    String value;
    63     bool important;
    64     bool disabled;
    65     bool parsedOk;
     63    bool important { false };
     64    bool disabled { false };
     65    bool parsedOk { false };
    6666    SourceRange range;
    6767};
  • trunk/Source/WebCore/css/CSSStyleRule.cpp

    r234825 r249013  
    113113String CSSStyleRule::cssText() const
    114114{
    115     StringBuilder result;
    116     result.append(selectorText());
    117     result.appendLiteral(" { ");
    118     String decls = m_styleRule->properties().asText();
    119     result.append(decls);
    120     if (!decls.isEmpty())
    121         result.append(' ');
    122     result.append('}');
    123     return result.toString();
     115    String declarations = m_styleRule->properties().asText();
     116    if (declarations.isEmpty())
     117        return makeString(selectorText(), " { }");
     118    return makeString(selectorText(), " { ", declarations, " }");
    124119}
    125120
  • trunk/Source/WebCore/css/parser/CSSParser.cpp

    r246490 r249013  
    247247RefPtr<CSSValue> CSSParser::parseFontFaceDescriptor(CSSPropertyID propertyID, const String& propertyValue, const CSSParserContext& context)
    248248{
    249     StringBuilder builder;
    250     builder.appendLiteral("@font-face { ");
    251     builder.append(getPropertyNameString(propertyID));
    252     builder.appendLiteral(" : ");
    253     builder.append(propertyValue);
    254     builder.appendLiteral("; }");
    255     RefPtr<StyleRuleBase> rule = parseRule(context, nullptr, builder.toString());
     249    String string = makeString("@font-face { ", getPropertyNameString(propertyID), " : ", propertyValue, "; }");
     250    RefPtr<StyleRuleBase> rule = parseRule(context, nullptr, string);
    256251    if (!rule || !rule->isFontFaceRule())
    257252        return nullptr;
  • trunk/Source/WebCore/html/canvas/CanvasRenderingContext2D.cpp

    r246285 r249013  
    112112        if (i)
    113113            serializedFont.append(',');
     114
    114115        // FIXME: We should append family directly to serializedFont rather than building a temporary string.
    115116        String family = fontDescription.familyAt(i);
     
    119120            family = makeString('"', family, '"');
    120121
    121         serializedFont.append(' ');
    122         serializedFont.append(family);
     122        serializedFont.append(' ', family);
    123123    }
    124124
  • trunk/Source/WebKit/ChangeLog

    r249006 r249013  
     12019-08-17  Darin Adler  <darin@apple.com>
     2
     3        Use makeString and multi-argument StringBuilder::append instead of less efficient multiple appends
     4        https://bugs.webkit.org/show_bug.cgi?id=200862
     5
     6        Reviewed by Ryosuke Niwa.
     7
     8        * Shared/mac/AuxiliaryProcessMac.mm:
     9        (WebKit::setAndSerializeSandboxParameters): Use one append instead of multiple.
     10
    1112019-08-22  Wenson Hsieh  <wenson_hsieh@apple.com>
    212
  • trunk/Source/WebKit/Shared/mac/AuxiliaryProcessMac.mm

    r248697 r249013  
    235235            CRASH();
    236236        }
    237         builder.append(name);
    238         builder.append(':');
    239         builder.append(value);
    240         builder.append(':');
     237        builder.append(name, ':', value, ':');
    241238    }
    242239    if (isProfilePath) {
  • trunk/Tools/ChangeLog

    r249004 r249013  
     12019-08-17  Darin Adler  <darin@apple.com>
     2
     3        Use makeString and multi-argument StringBuilder::append instead of less efficient multiple appends
     4        https://bugs.webkit.org/show_bug.cgi?id=200862
     5
     6        Reviewed by Ryosuke Niwa.
     7
     8        * WebKitTestRunner/InjectedBundle/TestRunner.cpp:
     9        (WTR::TestRunner::statisticsDidRunTelemetryCallback): Use makeString.
     10        * WebKitTestRunner/TestController.cpp:
     11        (WTR::TestController::findAndDumpWebKitProcessIdentifiers): Ditto.
     12        (WTR::TestController::downloadDidReceiveServerRedirectToURL): Ditto.
     13        (WTR::TestController::downloadDidFail): Ditto.
     14
    1152019-08-22  clopez@igalia.com  <clopez@igalia.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
    216
  • trunk/Tools/WebKitTestRunner/InjectedBundle/TestRunner.cpp

    r248856 r249013  
    19071907    JSContextRef context = WKBundleFrameGetJavaScriptContext(mainFrame);
    19081908   
    1909     StringBuilder stringBuilder;
    1910     stringBuilder.appendLiteral("{ \"totalPrevalentResources\" : ");
    1911     stringBuilder.appendNumber(totalPrevalentResources);
    1912     stringBuilder.appendLiteral(", \"totalPrevalentResourcesWithUserInteraction\" : ");
    1913     stringBuilder.appendNumber(totalPrevalentResourcesWithUserInteraction);
    1914     stringBuilder.appendLiteral(", \"top3SubframeUnderTopFrameOrigins\" : ");
    1915     stringBuilder.appendNumber(top3SubframeUnderTopFrameOrigins);
    1916     stringBuilder.appendLiteral(" }");
    1917    
    1918     JSValueRef result = JSValueMakeFromJSONString(context, adopt(JSStringCreateWithUTF8CString(stringBuilder.toString().utf8().data())).get());
     1909    String string = makeString("{ \"totalPrevalentResources\" : ", totalPrevalentResources, ", \"totalPrevalentResourcesWithUserInteraction\" : ", totalPrevalentResourcesWithUserInteraction, ", \"top3SubframeUnderTopFrameOrigins\" : ", top3SubframeUnderTopFrameOrigins, " }");
     1910   
     1911    JSValueRef result = JSValueMakeFromJSONString(context, adopt(JSStringCreateWithUTF8CString(string.utf8().data())).get());
    19191912
    19201913    callTestRunnerCallback(StatisticsDidRunTelemetryCallbackID, 1, &result);
  • trunk/Tools/WebKitTestRunner/TestController.cpp

    r249001 r249013  
    10951095void TestController::findAndDumpWebKitProcessIdentifiers()
    10961096{
    1097     StringBuilder builder;
    1098 
    10991097#if PLATFORM(COCOA)
    1100     builder.append(TestController::webProcessName());
    1101     builder.appendLiteral(": ");
    1102     pid_t webContentPID = WKPageGetProcessIdentifier(TestController::singleton().mainWebView()->page());
    1103     builder.appendNumber(webContentPID);
    1104     builder.append('\n');
    1105 
    1106     builder.append(TestController::networkProcessName());
    1107     builder.appendLiteral(": ");
    1108     pid_t networkingPID = WKContextGetNetworkProcessIdentifier(m_context.get());
    1109     builder.appendNumber(networkingPID);
    1110     builder.append('\n');
     1098    dumpResponse(makeString(TestController::webProcessName(), ": ",
     1099        WKPageGetProcessIdentifier(TestController::singleton().mainWebView()->page()), '\n',
     1100        TestController::networkProcessName(), ": ",
     1101        WKContextGetNetworkProcessIdentifier(m_context.get()), '\n'));
    11111102#else
    1112     builder.append('\n');
     1103    dumpResponse("\n"_s);
    11131104#endif
    1114 
    1115     dumpResponse(builder.toString());
    11161105}
    11171106
     
    24512440void TestController::downloadDidReceiveServerRedirectToURL(WKContextRef, WKDownloadRef, WKURLRef url)
    24522441{
    2453     if (m_shouldLogDownloadCallbacks) {
    2454         StringBuilder builder;
    2455         builder.appendLiteral("Download was redirected to \"");
    2456         WKRetainPtr<WKStringRef> urlStringWK = adoptWK(WKURLCopyString(url));
    2457         builder.append(toSTD(urlStringWK).c_str());
    2458         builder.appendLiteral("\".\n");
    2459         m_currentInvocation->outputText(builder.toString());
    2460     }
     2442    if (m_shouldLogDownloadCallbacks)
     2443        m_currentInvocation->outputText(makeString("Download was redirected to \"", toWTFString(adoptWK(WKURLCopyString(url))), "\".\n"));
    24612444}
    24622445
     
    24662449        m_currentInvocation->outputText("Download failed.\n"_s);
    24672450
    2468         WKRetainPtr<WKStringRef> errorDomain = adoptWK(WKErrorCopyDomain(error));
    2469         WKRetainPtr<WKStringRef> errorDescription = adoptWK(WKErrorCopyLocalizedDescription(error));
    2470         int errorCode = WKErrorGetErrorCode(error);
    2471 
    2472         StringBuilder errorBuilder;
    2473         errorBuilder.append("Failed: ");
    2474         errorBuilder.append(toWTFString(errorDomain));
    2475         errorBuilder.append(", code=");
    2476         errorBuilder.appendNumber(errorCode);
    2477         errorBuilder.append(", description=");
    2478         errorBuilder.append(toWTFString(errorDescription));
    2479         errorBuilder.append("\n");
    2480 
    2481         m_currentInvocation->outputText(errorBuilder.toString());
     2451        auto domain = toWTFString(adoptWK(WKErrorCopyDomain(error)));
     2452        auto description = toWTFString(adoptWK(WKErrorCopyLocalizedDescription(error)));
     2453        int code = WKErrorGetErrorCode(error);
     2454
     2455        m_currentInvocation->outputText(makeString("Failed: ", domain, ", code=", code, ", description=", description, "\n"));
    24822456    }
    24832457    m_currentInvocation->notifyDownloadDone();
Note: See TracChangeset for help on using the changeset viewer.