Title: [241256] trunk
Revision
241256
Author
[email protected]
Date
2019-02-10 22:02:05 -0800 (Sun, 10 Feb 2019)

Log Message

Switch uses of StringBuilder with String::format for hex numbers to use HexNumber.h instead
https://bugs.webkit.org/show_bug.cgi?id=194485

Reviewed by Daniel Bates.

Source/_javascript_Core:

* heap/HeapSnapshotBuilder.cpp:
(JSC::HeapSnapshotBuilder::json): Use appendUnsignedAsHex along with
reinterpret_cast<uintptr_t> to replace uses of String::format with "%p".

* runtime/JSGlobalObjectFunctions.cpp:
(JSC::encode): Removed some unneeded casts in StringBuilder code,
including one in a call to appendByteAsHex.
(JSC::globalFuncEscape): Ditto.

Source/WebCore:

* Modules/websockets/WebSocket.cpp:
(WebCore::encodeProtocolString): Use appendUnsignedAsHexFixedSize instead of String::format.

* css/parser/CSSParserToken.cpp:
(WebCore::CSSParserToken::serialize const): Fixed style of many return statements
that called a function returning void; doesn't match WebKit's prevailing style.
Also use break instead of return. Used appendLiteral instead of append in many
cases, and append character instead of single-character literal in others.
Use appendUnsignedAsHex instead of String::format.

* platform/graphics/opengl/GraphicsContext3DOpenGLCommon.cpp:
(WebCore::generateHashedName): Use appendUnsignedAsHex instad of appendUnsigned64AsHex.
Should come back here and use makeString once we make HexNumber.h work with that.

* platform/mac/WebCoreNSURLExtras.mm: Removed unnecessary include of HexNumber.h.

* rendering/RenderTreeAsText.cpp:
(WebCore::quoteAndEscapeNonPrintables): Use appendLiteral instead of multiple calls
to character append. Touched because it was next to a call to appendUnsignedAsHex.

Source/WebKit:

* UIProcess/DeviceIdHashSaltStorage.cpp:
(WebKit::DeviceIdHashSaltStorage::completeDeviceIdHashSaltForOriginCall): Use
appendUnsignedAsHex instead of appendUnsigned64AsHex.

* UIProcess/WebBackForwardList.cpp:
(WebKit::WebBackForwardList::loggingString): Use appendUnsignedAsHex and
reinterpret_cast<uintptr_t> instead of String::format and "%p".

Source/WTF:

* wtf/HexNumber.h: Removed unused functions placeByteAsHexCompressIfPossible and
placeByteAsHex. Can always bring them back if someone needs them. Updated
appendUnsignedAsHex to be a template so we can use it on any integer type,
got rid of unnecessary use of Vector and unnecessary reversing, and got rid of
appendUnsigned64AsHex since callers can now just use appendUnsignedAsHex.
Rewrote appendUnsignedAsHexFixedSize to share mode code rather than replicating.

* wtf/Logger.h: Use appendUnsignedAsHex instead of appendUnsigned64AsHex.

* wtf/URL.cpp: Removed unnecessary include of HexNumber.h.

* wtf/cocoa/NSURLExtras.h: Added missing include of Foundation.h that was
worked around in NSURLExtras.mm.
* wtf/cocoa/NSURLExtras.mm: Removed unnecessary includes of HexNumber.h
and Foundation.h.

Tools:

* WebKitTestRunner/TestController.cpp: Removed unnecessary include of HexNumber.h.

Modified Paths

Diff

Modified: trunk/Source/_javascript_Core/ChangeLog (241255 => 241256)


--- trunk/Source/_javascript_Core/ChangeLog	2019-02-11 04:10:08 UTC (rev 241255)
+++ trunk/Source/_javascript_Core/ChangeLog	2019-02-11 06:02:05 UTC (rev 241256)
@@ -1,3 +1,19 @@
+2019-02-10  Darin Adler  <[email protected]>
+
+        Switch uses of StringBuilder with String::format for hex numbers to use HexNumber.h instead
+        https://bugs.webkit.org/show_bug.cgi?id=194485
+
+        Reviewed by Daniel Bates.
+
+        * heap/HeapSnapshotBuilder.cpp:
+        (JSC::HeapSnapshotBuilder::json): Use appendUnsignedAsHex along with
+        reinterpret_cast<uintptr_t> to replace uses of String::format with "%p".
+
+        * runtime/JSGlobalObjectFunctions.cpp:
+        (JSC::encode): Removed some unneeded casts in StringBuilder code,
+        including one in a call to appendByteAsHex.
+        (JSC::globalFuncEscape): Ditto.
+
 2019-02-10  Commit Queue  <[email protected]>
 
         Unreviewed, rolling out r241230.

Modified: trunk/Source/_javascript_Core/heap/HeapSnapshotBuilder.cpp (241255 => 241256)


--- trunk/Source/_javascript_Core/heap/HeapSnapshotBuilder.cpp	2019-02-11 04:10:08 UTC (rev 241255)
+++ trunk/Source/_javascript_Core/heap/HeapSnapshotBuilder.cpp	2019-02-11 06:02:05 UTC (rev 241256)
@@ -34,6 +34,7 @@
 #include "JSCast.h"
 #include "PreventCollectionScope.h"
 #include "VM.h"
+#include <wtf/HexNumber.h>
 #include <wtf/text/StringBuilder.h>
 
 namespace JSC {
@@ -434,10 +435,11 @@
         if (m_snapshotType == SnapshotType::GCDebuggingSnapshot) {
             json.append(',');
             json.appendNumber(labelIndex);
-            json.append(',');
-            json.append(String::format("\"%p\"", node.cell)); // FIXME: Should add StringBuilder::appendAddress(void*).
-            json.append(',');
-            json.append(String::format("\"%p\"", wrappedAddress));
+            json.appendLiteral(",\"");
+            appendUnsignedAsHex(reinterpret_cast<uintptr_t>(node.cell), json, Lowercase);
+            json.appendLiteral("\",\"");
+            appendUnsignedAsHex(reinterpret_cast<uintptr_t>(wrappedAddress), json, Lowercase);
+            json.append('"');
         }
     };
 

Modified: trunk/Source/_javascript_Core/runtime/JSGlobalObjectFunctions.cpp (241255 => 241256)


--- trunk/Source/_javascript_Core/runtime/JSGlobalObjectFunctions.cpp	2019-02-11 04:10:08 UTC (rev 241255)
+++ trunk/Source/_javascript_Core/runtime/JSGlobalObjectFunctions.cpp	2019-02-11 06:02:05 UTC (rev 241256)
@@ -145,7 +145,7 @@
             // 4-d-vi-1. Let jOctet be the value at index j within Octets.
             // 4-d-vi-2. Let S be a String containing three code units "%XY" where XY are two uppercase hexadecimal digits encoding the value of jOctet.
             // 4-d-vi-3. Let R be a new String value computed by concatenating the previous value of R and S.
-            builder.append(static_cast<LChar>('%'));
+            builder.append('%');
             appendByteAsHex(utf8OctetsBuffer[index], builder);
         }
     }
@@ -600,8 +600,8 @@
                 if (doNotEscape.get(static_cast<LChar>(u)))
                     builder.append(*c);
                 else {
-                    builder.append(static_cast<LChar>('%'));
-                    appendByteAsHex(static_cast<LChar>(u), builder);
+                    builder.append('%');
+                    appendByteAsHex(u, builder);
                 }
             }
             return jsString(exec, builder.toString());
@@ -611,14 +611,13 @@
         for (unsigned k = 0; k < view.length(); k++, c++) {
             UChar u = c[0];
             if (u >= doNotEscape.size()) {
-                builder.append(static_cast<LChar>('%'));
-                builder.append(static_cast<LChar>('u'));
+                builder.appendLiteral("%u");
                 appendByteAsHex(u >> 8, builder);
                 appendByteAsHex(u & 0xFF, builder);
             } else if (doNotEscape.get(static_cast<LChar>(u)))
                 builder.append(*c);
             else {
-                builder.append(static_cast<LChar>('%'));
+                builder.append('%');
                 appendByteAsHex(u, builder);
             }
         }

Modified: trunk/Source/WTF/ChangeLog (241255 => 241256)


--- trunk/Source/WTF/ChangeLog	2019-02-11 04:10:08 UTC (rev 241255)
+++ trunk/Source/WTF/ChangeLog	2019-02-11 06:02:05 UTC (rev 241256)
@@ -1,3 +1,26 @@
+2019-02-10  Darin Adler  <[email protected]>
+
+        Switch uses of StringBuilder with String::format for hex numbers to use HexNumber.h instead
+        https://bugs.webkit.org/show_bug.cgi?id=194485
+
+        Reviewed by Daniel Bates.
+
+        * wtf/HexNumber.h: Removed unused functions placeByteAsHexCompressIfPossible and
+        placeByteAsHex. Can always bring them back if someone needs them. Updated
+        appendUnsignedAsHex to be a template so we can use it on any integer type,
+        got rid of unnecessary use of Vector and unnecessary reversing, and got rid of
+        appendUnsigned64AsHex since callers can now just use appendUnsignedAsHex.
+        Rewrote appendUnsignedAsHexFixedSize to share mode code rather than replicating.
+
+        * wtf/Logger.h: Use appendUnsignedAsHex instead of appendUnsigned64AsHex.
+
+        * wtf/URL.cpp: Removed unnecessary include of HexNumber.h.
+
+        * wtf/cocoa/NSURLExtras.h: Added missing include of Foundation.h that was
+        worked around in NSURLExtras.mm.
+        * wtf/cocoa/NSURLExtras.mm: Removed unnecessary includes of HexNumber.h
+        and Foundation.h.
+
 2019-02-09  Darin Adler  <[email protected]>
 
         Eliminate unnecessary String temporaries by using StringConcatenateNumbers

Modified: trunk/Source/WTF/wtf/HexNumber.h (241255 => 241256)


--- trunk/Source/WTF/wtf/HexNumber.h	2019-02-11 04:10:08 UTC (rev 241255)
+++ trunk/Source/WTF/wtf/HexNumber.h	2019-02-11 06:02:05 UTC (rev 241256)
@@ -20,6 +20,7 @@
 
 #pragma once
 
+#include <array>
 #include <wtf/text/StringConcatenate.h>
 
 namespace WTF {
@@ -45,67 +46,35 @@
     destination.append(hexDigits[byte & 0xF]);
 }
 
-template<typename T>
-inline void placeByteAsHexCompressIfPossible(unsigned char byte, T& destination, unsigned& index, HexConversionMode mode = Uppercase)
+template<typename NumberType, typename DestinationType>
+inline void appendUnsignedAsHex(NumberType number, DestinationType& destination, HexConversionMode mode = Uppercase)
 {
-    auto* hexDigits = Internal::hexDigitsForMode(mode);
-    if (byte >= 0x10)
-        destination[index++] = hexDigits[byte >> 4];
-    destination[index++] = hexDigits[byte & 0xF];
-}
-
-template<typename T>
-inline void placeByteAsHex(unsigned char byte, T& destination, HexConversionMode mode = Uppercase)
-{
-    auto* hexDigits = Internal::hexDigitsForMode(mode);
-    *destination++ = hexDigits[byte >> 4];
-    *destination++ = hexDigits[byte & 0xF];
-}
-
-template<typename T>
-inline void appendUnsignedAsHex(unsigned number, T& destination, HexConversionMode mode = Uppercase)
-{
-    auto* hexDigits = Internal::hexDigitsForMode(mode);
-    Vector<LChar, 8> result;
+    // Each byte can generate up to two digits.
+    std::array<LChar, sizeof(NumberType) * 2> buffer;
+    auto start = buffer.end();
+    auto unsignedNumber = static_cast<typename std::make_unsigned<NumberType>::type>(number);
+    auto hexDigits = Internal::hexDigitsForMode(mode);
     do {
-        result.append(hexDigits[number % 16]);
-        number >>= 4;
-    } while (number > 0);
-
-    result.reverse();
-    destination.append(result.data(), result.size());
+        ASSERT(start > buffer.begin());
+        *--start = hexDigits[unsignedNumber & 0xF];
+        unsignedNumber >>= 4;
+    } while (unsignedNumber);
+    destination.append(&*start, buffer.end() - start);
 }
-    
-template<typename T>
-inline void appendUnsigned64AsHex(uint64_t number, T& destination, HexConversionMode mode = Uppercase)
-{
-    auto* hexDigits = Internal::hexDigitsForMode(mode);
-    Vector<LChar, 8> result;
-    do {
-        result.append(hexDigits[number % 16]);
-        number >>= 4;
-    } while (number > 0);
-    
-    result.reverse();
-    destination.append(result.data(), result.size());
-}
 
-// Same as appendUnsignedAsHex, but using exactly 'desiredDigits' for the conversion.
-template<typename T>
-inline void appendUnsignedAsHexFixedSize(unsigned number, T& destination, unsigned desiredDigits, HexConversionMode mode = Uppercase)
+// Same as appendUnsignedAsHex, but zero-padding to get at least the desired number of digits.
+template<typename NumberType, typename DestinationType>
+inline void appendUnsignedAsHexFixedSize(NumberType number, DestinationType& destination, unsigned desiredDigits, HexConversionMode mode = Uppercase)
 {
-    ASSERT(desiredDigits);
-
-    auto* hexDigits = Internal::hexDigitsForMode(mode);
-    Vector<LChar, 8> result;
+    unsigned digits = 0;
+    auto unsignedNumber = static_cast<typename std::make_unsigned<NumberType>::type>(number);
     do {
-        result.append(hexDigits[number % 16]);
-        number >>= 4;
-    } while (result.size() < desiredDigits);
-
-    ASSERT(result.size() == desiredDigits);
-    result.reverse();
-    destination.append(result.data(), result.size());
+        ++digits;
+        unsignedNumber >>= 4;
+    } while (unsignedNumber);
+    for (; digits < desiredDigits; ++digits)
+        destination.append('0');
+    appendUnsignedAsHex(number, destination, mode);
 }
 
 } // namespace WTF
@@ -113,6 +82,4 @@
 using WTF::appendByteAsHex;
 using WTF::appendUnsignedAsHex;
 using WTF::appendUnsignedAsHexFixedSize;
-using WTF::placeByteAsHex;
-using WTF::placeByteAsHexCompressIfPossible;
 using WTF::Lowercase;

Modified: trunk/Source/WTF/wtf/Logger.h (241255 => 241256)


--- trunk/Source/WTF/wtf/Logger.h	2019-02-11 04:10:08 UTC (rev 241255)
+++ trunk/Source/WTF/wtf/Logger.h	2019-02-11 06:02:05 UTC (rev 241256)
@@ -272,7 +272,7 @@
         }
         builder.append(value.methodName);
         builder.append('(');
-        appendUnsigned64AsHex(value.objectPtr, builder);
+        appendUnsignedAsHex(value.objectPtr, builder);
         builder.appendLiteral(") ");
         return builder.toString();
     }

Modified: trunk/Source/WTF/wtf/URL.cpp (241255 => 241256)


--- trunk/Source/WTF/wtf/URL.cpp	2019-02-11 04:10:08 UTC (rev 241255)
+++ trunk/Source/WTF/wtf/URL.cpp	2019-02-11 06:02:05 UTC (rev 241256)
@@ -31,7 +31,6 @@
 #include <stdio.h>
 #include <unicode/uidna.h>
 #include <wtf/HashMap.h>
-#include <wtf/HexNumber.h>
 #include <wtf/NeverDestroyed.h>
 #include <wtf/StdLibExtras.h>
 #include <wtf/UUID.h>

Modified: trunk/Source/WTF/wtf/cocoa/NSURLExtras.h (241255 => 241256)


--- trunk/Source/WTF/wtf/cocoa/NSURLExtras.h	2019-02-11 04:10:08 UTC (rev 241255)
+++ trunk/Source/WTF/wtf/cocoa/NSURLExtras.h	2019-02-11 06:02:05 UTC (rev 241256)
@@ -28,8 +28,7 @@
 
 #pragma once
 
-@class NSString;
-@class NSURL;
+#import <Foundation/Foundation.h>
 
 namespace WTF {
 

Modified: trunk/Source/WTF/wtf/cocoa/NSURLExtras.mm (241255 => 241256)


--- trunk/Source/WTF/wtf/cocoa/NSURLExtras.mm	2019-02-11 04:10:08 UTC (rev 241255)
+++ trunk/Source/WTF/wtf/cocoa/NSURLExtras.mm	2019-02-11 06:02:05 UTC (rev 241256)
@@ -27,11 +27,9 @@
  */
 
 #import "config.h"
-#import <Foundation/Foundation.h>
 #import "NSURLExtras.h"
 
 #import <wtf/Function.h>
-#import <wtf/HexNumber.h>
 #import <wtf/ObjCRuntimeExtras.h>
 #import <wtf/RetainPtr.h>
 #import <wtf/URLHelpers.h>

Modified: trunk/Source/WebCore/ChangeLog (241255 => 241256)


--- trunk/Source/WebCore/ChangeLog	2019-02-11 04:10:08 UTC (rev 241255)
+++ trunk/Source/WebCore/ChangeLog	2019-02-11 06:02:05 UTC (rev 241256)
@@ -1,3 +1,30 @@
+2019-02-10  Darin Adler  <[email protected]>
+
+        Switch uses of StringBuilder with String::format for hex numbers to use HexNumber.h instead
+        https://bugs.webkit.org/show_bug.cgi?id=194485
+
+        Reviewed by Daniel Bates.
+
+        * Modules/websockets/WebSocket.cpp:
+        (WebCore::encodeProtocolString): Use appendUnsignedAsHexFixedSize instead of String::format.
+
+        * css/parser/CSSParserToken.cpp:
+        (WebCore::CSSParserToken::serialize const): Fixed style of many return statements
+        that called a function returning void; doesn't match WebKit's prevailing style.
+        Also use break instead of return. Used appendLiteral instead of append in many
+        cases, and append character instead of single-character literal in others.
+        Use appendUnsignedAsHex instead of String::format.
+
+        * platform/graphics/opengl/GraphicsContext3DOpenGLCommon.cpp:
+        (WebCore::generateHashedName): Use appendUnsignedAsHex instad of appendUnsigned64AsHex.
+        Should come back here and use makeString once we make HexNumber.h work with that.
+
+        * platform/mac/WebCoreNSURLExtras.mm: Removed unnecessary include of HexNumber.h.
+
+        * rendering/RenderTreeAsText.cpp:
+        (WebCore::quoteAndEscapeNonPrintables): Use appendLiteral instead of multiple calls
+        to character append. Touched because it was next to a call to appendUnsignedAsHex.
+
 2019-02-10  Pablo Saavedra  <[email protected]>
 
         libWPEWebKit-0.1.so: undefined reference to `JSC::JSValue::asCell() const

Modified: trunk/Source/WebCore/Modules/websockets/WebSocket.cpp (241255 => 241256)


--- trunk/Source/WebCore/Modules/websockets/WebSocket.cpp	2019-02-11 04:10:08 UTC (rev 241255)
+++ trunk/Source/WebCore/Modules/websockets/WebSocket.cpp	2019-02-11 06:02:05 UTC (rev 241256)
@@ -98,9 +98,10 @@
 {
     StringBuilder builder;
     for (size_t i = 0; i < protocol.length(); i++) {
-        if (protocol[i] < 0x20 || protocol[i] > 0x7E)
-            builder.append(String::format("\\u%04X", protocol[i]));
-        else if (protocol[i] == 0x5c)
+        if (protocol[i] < 0x20 || protocol[i] > 0x7E) {
+            builder.appendLiteral("\\u");
+            appendUnsignedAsHexFixedSize(protocol[i], builder, 4);
+        } else if (protocol[i] == 0x5c)
             builder.appendLiteral("\\\\");
         else
             builder.append(protocol[i]);

Modified: trunk/Source/WebCore/css/parser/CSSParserToken.cpp (241255 => 241256)


--- trunk/Source/WebCore/css/parser/CSSParserToken.cpp	2019-02-11 04:10:08 UTC (rev 241255)
+++ trunk/Source/WebCore/css/parser/CSSParserToken.cpp	2019-02-11 06:02:05 UTC (rev 241256)
@@ -34,6 +34,7 @@
 #include "CSSPrimitiveValue.h"
 #include "CSSPropertyParser.h"
 #include <limits.h>
+#include <wtf/HexNumber.h>
 #include <wtf/text/StringBuilder.h>
 
 namespace WebCore {
@@ -392,7 +393,8 @@
         break;
     case FunctionToken:
         serializeIdentifier(value().toString(), builder);
-        return builder.append('(');
+        builder.append('(');
+        break;
     case AtKeywordToken:
         builder.append('@');
         serializeIdentifier(value().toString(), builder);
@@ -402,21 +404,27 @@
         serializeIdentifier(value().toString(), builder, (getHashTokenType() == HashTokenUnrestricted));
         break;
     case UrlToken:
-        builder.append("url(");
+        builder.appendLiteral("url(");
         serializeIdentifier(value().toString(), builder);
-        return builder.append(')');
+        builder.append(')');
+        break;
     case DelimiterToken:
-        if (delimiter() == '\\')
-            return builder.append("\\\n");
-        return builder.append(delimiter());
+        if (delimiter() == '\\') {
+            builder.appendLiteral("\\\n");
+            break;
+        }
+        builder.append(delimiter());
+        break;
     case NumberToken:
         // These won't properly preserve the NumericValueType flag
         if (m_numericSign == PlusSign)
             builder.append('+');
-        return builder.appendNumber(numericValue());
+        builder.appendNumber(numericValue());
+        break;
     case PercentageToken:
         builder.appendNumber(numericValue());
-        return builder.append('%');
+        builder.append('%');
+        break;
     case DimensionToken:
         // This will incorrectly serialize e.g. 4e3e2 as 4000e2
         builder.appendNumber(numericValue());
@@ -423,55 +431,80 @@
         serializeIdentifier(value().toString(), builder);
         break;
     case UnicodeRangeToken:
-        return builder.append(String::format("U+%X-%X", unicodeRangeStart(), unicodeRangeEnd()));
+        builder.appendLiteral("U+");
+        appendUnsignedAsHex(unicodeRangeStart(), builder);
+        builder.append('-');
+        appendUnsignedAsHex(unicodeRangeEnd(), builder);
+        break;
     case StringToken:
-        return serializeString(value().toString(), builder);
+        serializeString(value().toString(), builder);
+        break;
 
     case IncludeMatchToken:
-        return builder.append("~=");
+        builder.appendLiteral("~=");
+        break;
     case DashMatchToken:
-        return builder.append("|=");
+        builder.appendLiteral("|=");
+        break;
     case PrefixMatchToken:
-        return builder.append("^=");
+        builder.appendLiteral("^=");
+        break;
     case SuffixMatchToken:
-        return builder.append("$=");
+        builder.appendLiteral("$=");
+        break;
     case SubstringMatchToken:
-        return builder.append("*=");
+        builder.appendLiteral("*=");
+        break;
     case ColumnToken:
-        return builder.append("||");
+        builder.appendLiteral("||");
+        break;
     case CDOToken:
-        return builder.append("<!--");
+        builder.appendLiteral("<!--");
+        break;
     case CDCToken:
-        return builder.append("-->");
+        builder.appendLiteral("-->");
+        break;
     case BadStringToken:
-        return builder.append("'\n");
+        builder.appendLiteral("'\n");
+        break;
     case BadUrlToken:
-        return builder.append("url(()");
+        builder.appendLiteral("url(()");
+        break;
     case WhitespaceToken:
-        return builder.append(' ');
+        builder.append(' ');
+        break;
     case ColonToken:
-        return builder.append(':');
+        builder.append(':');
+        break;
     case SemicolonToken:
-        return builder.append(';');
+        builder.append(';');
+        break;
     case CommaToken:
-        return builder.append(',');
+        builder.append(',');
+        break;
     case LeftParenthesisToken:
-        return builder.append('(');
+        builder.append('(');
+        break;
     case RightParenthesisToken:
-        return builder.append(')');
+        builder.append(')');
+        break;
     case LeftBracketToken:
-        return builder.append('[');
+        builder.append('[');
+        break;
     case RightBracketToken:
-        return builder.append(']');
+        builder.append(']');
+        break;
     case LeftBraceToken:
-        return builder.append('{');
+        builder.append('{');
+        break;
     case RightBraceToken:
-        return builder.append('}');
+        builder.append('}');
+        break;
 
     case EOFToken:
     case CommentToken:
         ASSERT_NOT_REACHED();
-        return;
+        break;
     }
 }
 

Modified: trunk/Source/WebCore/platform/graphics/opengl/GraphicsContext3DOpenGLCommon.cpp (241255 => 241256)


--- trunk/Source/WebCore/platform/graphics/opengl/GraphicsContext3DOpenGLCommon.cpp	2019-02-11 04:10:08 UTC (rev 241255)
+++ trunk/Source/WebCore/platform/graphics/opengl/GraphicsContext3DOpenGLCommon.cpp	2019-02-11 06:02:05 UTC (rev 241256)
@@ -975,7 +975,7 @@
     uint64_t number = nameHashForShader(name.utf8().data(), name.length());
     StringBuilder builder;
     builder.appendLiteral("webgl_");
-    appendUnsigned64AsHex(number, builder, Lowercase);
+    appendUnsignedAsHex(number, builder, Lowercase);
     return builder.toString();
 }
 

Modified: trunk/Source/WebCore/platform/mac/WebCoreNSURLExtras.mm (241255 => 241256)


--- trunk/Source/WebCore/platform/mac/WebCoreNSURLExtras.mm	2019-02-11 04:10:08 UTC (rev 241255)
+++ trunk/Source/WebCore/platform/mac/WebCoreNSURLExtras.mm	2019-02-11 06:02:05 UTC (rev 241256)
@@ -28,9 +28,9 @@
 
 #import "config.h"
 #import "WebCoreNSURLExtras.h"
+
 #import <pal/spi/cf/CFNetworkSPI.h>
 #import <wtf/Function.h>
-#import <wtf/HexNumber.h>
 #import <wtf/ObjCRuntimeExtras.h>
 #import <wtf/RetainPtr.h>
 #import <wtf/Vector.h>

Modified: trunk/Source/WebCore/rendering/RenderTreeAsText.cpp (241255 => 241256)


--- trunk/Source/WebCore/rendering/RenderTreeAsText.cpp	2019-02-11 04:10:08 UTC (rev 241255)
+++ trunk/Source/WebCore/rendering/RenderTreeAsText.cpp	2019-02-11 06:02:05 UTC (rev 241256)
@@ -150,11 +150,9 @@
     for (unsigned i = 0; i != s.length(); ++i) {
         UChar c = s[i];
         if (c == '\\') {
-            result.append('\\');
-            result.append('\\');
+            result.appendLiteral("\\\\");
         } else if (c == '"') {
-            result.append('\\');
-            result.append('"');
+            result.appendLiteral("\\\"");
         } else if (c == '\n' || c == noBreakSpace)
             result.append(' ');
         else {
@@ -161,10 +159,8 @@
             if (c >= 0x20 && c < 0x7F)
                 result.append(c);
             else {
-                result.append('\\');
-                result.append('x');
-                result.append('{');
-                appendUnsignedAsHex(c, result); 
+                result.appendLiteral("\\x{");
+                appendUnsignedAsHex(c, result);
                 result.append('}');
             }
         }

Modified: trunk/Source/WebKit/ChangeLog (241255 => 241256)


--- trunk/Source/WebKit/ChangeLog	2019-02-11 04:10:08 UTC (rev 241255)
+++ trunk/Source/WebKit/ChangeLog	2019-02-11 06:02:05 UTC (rev 241256)
@@ -1,3 +1,18 @@
+2019-02-10  Darin Adler  <[email protected]>
+
+        Switch uses of StringBuilder with String::format for hex numbers to use HexNumber.h instead
+        https://bugs.webkit.org/show_bug.cgi?id=194485
+
+        Reviewed by Daniel Bates.
+
+        * UIProcess/DeviceIdHashSaltStorage.cpp:
+        (WebKit::DeviceIdHashSaltStorage::completeDeviceIdHashSaltForOriginCall): Use
+        appendUnsignedAsHex instead of appendUnsigned64AsHex.
+
+        * UIProcess/WebBackForwardList.cpp:
+        (WebKit::WebBackForwardList::loggingString): Use appendUnsignedAsHex and
+        reinterpret_cast<uintptr_t> instead of String::format and "%p".
+
 2019-02-10  Commit Queue  <[email protected]>
 
         Unreviewed, rolling out r241167.

Modified: trunk/Source/WebKit/UIProcess/DeviceIdHashSaltStorage.cpp (241255 => 241256)


--- trunk/Source/WebKit/UIProcess/DeviceIdHashSaltStorage.cpp	2019-02-11 04:10:08 UTC (rev 241255)
+++ trunk/Source/WebKit/UIProcess/DeviceIdHashSaltStorage.cpp	2019-02-11 06:02:05 UTC (rev 241256)
@@ -215,7 +215,7 @@
         StringBuilder builder;
         builder.reserveCapacity(hashSaltSize);
         for (unsigned i = 0; i < randomDataSize; i++)
-            appendUnsigned64AsHex(randomData[i], builder);
+            appendUnsignedAsHex(randomData[i], builder);
 
         String deviceIdHashSalt = builder.toString();
 

Modified: trunk/Source/WebKit/UIProcess/WebBackForwardList.cpp (241255 => 241256)


--- trunk/Source/WebKit/UIProcess/WebBackForwardList.cpp	2019-02-11 04:10:08 UTC (rev 241255)
+++ trunk/Source/WebKit/UIProcess/WebBackForwardList.cpp	2019-02-11 06:02:05 UTC (rev 241256)
@@ -33,6 +33,7 @@
 #include <WebCore/DiagnosticLoggingClient.h>
 #include <WebCore/DiagnosticLoggingKeys.h>
 #include <wtf/DebugUtilities.h>
+#include <wtf/HexNumber.h>
 #include <wtf/text/StringBuilder.h>
 
 namespace WebKit {
@@ -473,25 +474,34 @@
 #endif
 }
 
+#if !LOG_DISABLED
 
-#if !LOG_DISABLED
 const char* WebBackForwardList::loggingString()
 {
     StringBuilder builder;
-    builder.append(String::format("WebBackForwardList %p - %zu entries, has current index %s (%zu)", this, m_entries.size(), m_currentIndex ? "YES" : "NO", m_currentIndex ? *m_currentIndex : 0));
 
+    builder.appendLiteral("WebBackForwardList ");
+    appendUnsignedAsHex(reinterpret_cast<uintptr_t>(this), builder);
+    builder.appendLiteral(" - ");
+    builder.appendNumber(m_entries.size());
+    builder.appendLiteral(" entries, has current index ");
+    builder.append(m_currentIndex ? "YES" : "NO");
+    builder.appendLiteral(" (");
+    builder.appendNumber(m_currentIndex ? *m_currentIndex : 0);
+    builder.append(')');
+
     for (size_t i = 0; i < m_entries.size(); ++i) {
-        builder.append("\n");
+        builder.append('\n');
         if (m_currentIndex && *m_currentIndex == i)
-            builder.append(" * ");
+            builder.appendLiteral(" * ");
         else
-            builder.append(" - ");
-
+            builder.appendLiteral(" - ");
         builder.append(m_entries[i]->loggingString());
     }
 
     return debugString("\n", builder.toString());
 }
+
 #endif // !LOG_DISABLED
 
 } // namespace WebKit

Modified: trunk/Tools/ChangeLog (241255 => 241256)


--- trunk/Tools/ChangeLog	2019-02-11 04:10:08 UTC (rev 241255)
+++ trunk/Tools/ChangeLog	2019-02-11 06:02:05 UTC (rev 241256)
@@ -1,3 +1,12 @@
+2019-02-10  Darin Adler  <[email protected]>
+
+        Switch uses of StringBuilder with String::format for hex numbers to use HexNumber.h instead
+        https://bugs.webkit.org/show_bug.cgi?id=194485
+
+        Reviewed by Daniel Bates.
+
+        * WebKitTestRunner/TestController.cpp: Removed unnecessary include of HexNumber.h.
+
 2019-02-09  Benjamin Poulain  <[email protected]>
 
         Add more tests for clampTo<>()

Modified: trunk/Tools/WebKitTestRunner/TestController.cpp (241255 => 241256)


--- trunk/Tools/WebKitTestRunner/TestController.cpp	2019-02-11 04:10:08 UTC (rev 241255)
+++ trunk/Tools/WebKitTestRunner/TestController.cpp	2019-02-11 06:02:05 UTC (rev 241256)
@@ -70,7 +70,6 @@
 #include <string>
 #include <wtf/AutodrainedPool.h>
 #include <wtf/CryptographicallyRandomNumber.h>
-#include <wtf/HexNumber.h>
 #include <wtf/MainThread.h>
 #include <wtf/ProcessPrivilege.h>
 #include <wtf/RefCounted.h>
_______________________________________________
webkit-changes mailing list
[email protected]
https://lists.webkit.org/mailman/listinfo/webkit-changes

Reply via email to