WebKit Bugzilla
Attachment 361649 Details for
Bug 194485
: Switch uses of StringBuilder with String::format for hex numbers to use HexNumber.h instead
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Requests
|
Help
|
New Account
|
Log In
Remember
[x]
|
Forgot Password
Login:
[x]
[patch]
Patch
bug-194485-20190210162930.patch (text/plain), 26.95 KB, created by
Darin Adler
on 2019-02-10 16:29:31 PST
(
hide
)
Description:
Patch
Filename:
MIME Type:
Creator:
Darin Adler
Created:
2019-02-10 16:29:31 PST
Size:
26.95 KB
patch
obsolete
>Subversion Revision: 241252 >diff --git a/Source/JavaScriptCore/ChangeLog b/Source/JavaScriptCore/ChangeLog >index 562101bcb5c53d11fdc0f163e129b76d9173ba06..65ca20ffd486434321b1f8db9bb4815ca8a9d40c 100644 >--- a/Source/JavaScriptCore/ChangeLog >+++ b/Source/JavaScriptCore/ChangeLog >@@ -1,3 +1,19 @@ >+2019-02-10 Darin Adler <darin@apple.com> >+ >+ 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 NOBODY (OOPS!). >+ >+ * 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-09 Yusuke Suzuki <ysuzuki@apple.com> > > Unreviewed, Lexer should use isLatin1 implementation in WTF >diff --git a/Source/WTF/ChangeLog b/Source/WTF/ChangeLog >index f7aabbd0da8deb4d87868c25bb2de939b402f723..934d62e12f5519c837a8e407fe918d676a62636c 100644 >--- a/Source/WTF/ChangeLog >+++ b/Source/WTF/ChangeLog >@@ -1,3 +1,26 @@ >+2019-02-10 Darin Adler <darin@apple.com> >+ >+ 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 NOBODY (OOPS!). >+ >+ * 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 <darin@apple.com> > > Eliminate unnecessary String temporaries by using StringConcatenateNumbers >diff --git a/Source/WebCore/ChangeLog b/Source/WebCore/ChangeLog >index 5b18bd844f9ee1331bbda90db1c9ce52963d1ab3..74bbecd2c09271077a200bd961af54f31f7bee3c 100644 >--- a/Source/WebCore/ChangeLog >+++ b/Source/WebCore/ChangeLog >@@ -1,3 +1,30 @@ >+2019-02-10 Darin Adler <darin@apple.com> >+ >+ 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 NOBODY (OOPS!). >+ >+ * 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 Philippe Normand <pnormand@igalia.com> > > Unreviewed, GTK Debug build fix after r241148. >diff --git a/Source/WebKit/ChangeLog b/Source/WebKit/ChangeLog >index edc4b128daeee8a25c36bec7968091d7bcff16e4..8f29db1c4e337307a816da38e9ad11fa9cac29fc 100644 >--- a/Source/WebKit/ChangeLog >+++ b/Source/WebKit/ChangeLog >@@ -1,3 +1,18 @@ >+2019-02-10 Darin Adler <darin@apple.com> >+ >+ 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 NOBODY (OOPS!). >+ >+ * 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 <commit-queue@webkit.org> > > Unreviewed, rolling out r241167. >diff --git a/Source/JavaScriptCore/heap/HeapSnapshotBuilder.cpp b/Source/JavaScriptCore/heap/HeapSnapshotBuilder.cpp >index 303a1f7d5b587f8c89726e2484e2cc954aab0007..cd91f800f80d664a11332463492e63c8ca31c0ca 100644 >--- a/Source/JavaScriptCore/heap/HeapSnapshotBuilder.cpp >+++ b/Source/JavaScriptCore/heap/HeapSnapshotBuilder.cpp >@@ -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 @@ String HeapSnapshotBuilder::json(Function<bool (const HeapSnapshotNode&)> allowN > 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('"'); > } > }; > >diff --git a/Source/JavaScriptCore/runtime/JSGlobalObjectFunctions.cpp b/Source/JavaScriptCore/runtime/JSGlobalObjectFunctions.cpp >index 68a82c23a43b9712452936f226c9d5f838d05bb9..17ee33f049f28ff0cdc9ad669d76f3e1c6e83855 100644 >--- a/Source/JavaScriptCore/runtime/JSGlobalObjectFunctions.cpp >+++ b/Source/JavaScriptCore/runtime/JSGlobalObjectFunctions.cpp >@@ -145,7 +145,7 @@ static JSValue encode(ExecState* exec, const Bitmap<256>& doNotEscape, const Cha > // 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 @@ EncodedJSValue JSC_HOST_CALL globalFuncEscape(ExecState* exec) > 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 @@ EncodedJSValue JSC_HOST_CALL globalFuncEscape(ExecState* exec) > 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); > } > } >diff --git a/Source/WTF/wtf/HexNumber.h b/Source/WTF/wtf/HexNumber.h >index c67b71edc09c9be6de657670b714344f20d89170..3d1265fa137e4eee0a7a4e3d779a703909cc106f 100644 >--- a/Source/WTF/wtf/HexNumber.h >+++ b/Source/WTF/wtf/HexNumber.h >@@ -20,6 +20,7 @@ > > #pragma once > >+#include <array> > #include <wtf/text/StringConcatenate.h> > > namespace WTF { >@@ -45,67 +46,35 @@ inline void appendByteAsHex(unsigned char byte, T& destination, HexConversionMod > destination.append(hexDigits[byte & 0xF]); > } > >-template<typename T> >-inline void placeByteAsHexCompressIfPossible(unsigned char byte, T& destination, unsigned& index, 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) >+template<typename NumberType, typename DestinationType> >+inline void appendUnsignedAsHex(NumberType number, DestinationType& 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()); >-} >- >-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()); >+ ASSERT(start > buffer.begin()); >+ *--start = hexDigits[unsignedNumber & 0xF]; >+ unsignedNumber >>= 4; >+ } while (unsignedNumber); >+ destination.append(start, buffer.end() - start); > } > >-// 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 @@ inline void appendUnsignedAsHexFixedSize(unsigned number, T& destination, unsign > using WTF::appendByteAsHex; > using WTF::appendUnsignedAsHex; > using WTF::appendUnsignedAsHexFixedSize; >-using WTF::placeByteAsHex; >-using WTF::placeByteAsHexCompressIfPossible; > using WTF::Lowercase; >diff --git a/Source/WTF/wtf/Logger.h b/Source/WTF/wtf/Logger.h >index a8883e837e4ab2dc31b77315a36ff2278ff2d75c..2897d00af7ec6e95fb5d08e6116212b2827a6efc 100644 >--- a/Source/WTF/wtf/Logger.h >+++ b/Source/WTF/wtf/Logger.h >@@ -272,7 +272,7 @@ struct LogArgument<Logger::LogSiteIdentifier> { > } > builder.append(value.methodName); > builder.append('('); >- appendUnsigned64AsHex(value.objectPtr, builder); >+ appendUnsignedAsHex(value.objectPtr, builder); > builder.appendLiteral(") "); > return builder.toString(); > } >diff --git a/Source/WTF/wtf/URL.cpp b/Source/WTF/wtf/URL.cpp >index b78db9f1c8f11ec12d93413bd85984f18b60ca06..fa001a851b8497672ece34edd8b1586510e2579e 100644 >--- a/Source/WTF/wtf/URL.cpp >+++ b/Source/WTF/wtf/URL.cpp >@@ -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> >diff --git a/Source/WTF/wtf/cocoa/NSURLExtras.h b/Source/WTF/wtf/cocoa/NSURLExtras.h >index 53371248e4c15e683c3a7c7d3490718d13ee18c9..bb6dcc23251b488aa176cd6325009e53261f9522 100644 >--- a/Source/WTF/wtf/cocoa/NSURLExtras.h >+++ b/Source/WTF/wtf/cocoa/NSURLExtras.h >@@ -28,8 +28,7 @@ > > #pragma once > >-@class NSString; >-@class NSURL; >+#import <Foundation/Foundation.h> > > namespace WTF { > >diff --git a/Source/WTF/wtf/cocoa/NSURLExtras.mm b/Source/WTF/wtf/cocoa/NSURLExtras.mm >index df8b83116d4857160de913f001816e69762531ce..56f1f3d52bbf32ba13ddd146d842921dfd7dbd48 100644 >--- a/Source/WTF/wtf/cocoa/NSURLExtras.mm >+++ b/Source/WTF/wtf/cocoa/NSURLExtras.mm >@@ -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> >diff --git a/Source/WebCore/Modules/websockets/WebSocket.cpp b/Source/WebCore/Modules/websockets/WebSocket.cpp >index c85a035d52fb7ec65400e43967a28f10c6960008..5e9ea526f5da3c74a9229bcff1c88f92c3f9667b 100644 >--- a/Source/WebCore/Modules/websockets/WebSocket.cpp >+++ b/Source/WebCore/Modules/websockets/WebSocket.cpp >@@ -98,9 +98,10 @@ static String encodeProtocolString(const String& protocol) > { > 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]); >diff --git a/Source/WebCore/css/parser/CSSParserToken.cpp b/Source/WebCore/css/parser/CSSParserToken.cpp >index 7b8e6033c6f525a95cf09cb15ce71c668fb26de9..a1135aa820ef88174a7cbb45c2979536b6329095 100644 >--- a/Source/WebCore/css/parser/CSSParserToken.cpp >+++ b/Source/WebCore/css/parser/CSSParserToken.cpp >@@ -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 @@ void CSSParserToken::serialize(StringBuilder& builder) const > break; > case FunctionToken: > serializeIdentifier(value().toString(), builder); >- return builder.append('('); >+ builder.append('('); >+ break; > case AtKeywordToken: > builder.append('@'); > serializeIdentifier(value().toString(), builder); >@@ -402,76 +404,107 @@ void CSSParserToken::serialize(StringBuilder& builder) const > 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()); > 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; > } > } > >diff --git a/Source/WebCore/platform/graphics/opengl/GraphicsContext3DOpenGLCommon.cpp b/Source/WebCore/platform/graphics/opengl/GraphicsContext3DOpenGLCommon.cpp >index de253338bcac6bb90fce5aadec301e1fea26e608..d3692a77f87a33c8e5af865f279cb9f49e68f937 100644 >--- a/Source/WebCore/platform/graphics/opengl/GraphicsContext3DOpenGLCommon.cpp >+++ b/Source/WebCore/platform/graphics/opengl/GraphicsContext3DOpenGLCommon.cpp >@@ -975,7 +975,7 @@ static String generateHashedName(const String& name) > 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(); > } > >diff --git a/Source/WebCore/platform/mac/WebCoreNSURLExtras.mm b/Source/WebCore/platform/mac/WebCoreNSURLExtras.mm >index d365b316777846347ccf235b763faff3309657fd..38368ec247dd0044ab9daae8df640590dd02028b 100644 >--- a/Source/WebCore/platform/mac/WebCoreNSURLExtras.mm >+++ b/Source/WebCore/platform/mac/WebCoreNSURLExtras.mm >@@ -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> >diff --git a/Source/WebCore/rendering/RenderTreeAsText.cpp b/Source/WebCore/rendering/RenderTreeAsText.cpp >index 8fd301f31c3c838148b309a55cec4a676a1518dd..7313c6b21a038dd4dc546046630ab9af53a95a22 100644 >--- a/Source/WebCore/rendering/RenderTreeAsText.cpp >+++ b/Source/WebCore/rendering/RenderTreeAsText.cpp >@@ -150,21 +150,17 @@ String quoteAndEscapeNonPrintables(StringView s) > 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 { > 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('}'); > } > } >diff --git a/Source/WebKit/UIProcess/DeviceIdHashSaltStorage.cpp b/Source/WebKit/UIProcess/DeviceIdHashSaltStorage.cpp >index 19a7a12cfa3f31bf1e2137c35cd57d0a507b9a9f..a2d0386acf5d8ad535c7912a886cbd0f00547868 100644 >--- a/Source/WebKit/UIProcess/DeviceIdHashSaltStorage.cpp >+++ b/Source/WebKit/UIProcess/DeviceIdHashSaltStorage.cpp >@@ -215,7 +215,7 @@ void DeviceIdHashSaltStorage::completeDeviceIdHashSaltForOriginCall(SecurityOrig > StringBuilder builder; > builder.reserveCapacity(hashSaltSize); > for (unsigned i = 0; i < randomDataSize; i++) >- appendUnsigned64AsHex(randomData[i], builder); >+ appendUnsignedAsHex(randomData[i], builder); > > String deviceIdHashSalt = builder.toString(); > >diff --git a/Source/WebKit/UIProcess/WebBackForwardList.cpp b/Source/WebKit/UIProcess/WebBackForwardList.cpp >index 7564f3c36cac6dee305a8d9625d30d10c690b8ac..d6a2938e18a6519e32074f13ee83b3776b14170e 100644 >--- a/Source/WebKit/UIProcess/WebBackForwardList.cpp >+++ b/Source/WebKit/UIProcess/WebBackForwardList.cpp >@@ -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 @@ void WebBackForwardList::didRemoveItem(WebBackForwardListItem& backForwardListIt > #endif > } > >- > #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 >diff --git a/Tools/ChangeLog b/Tools/ChangeLog >index 26456d168ee7df5133a320929e08d7f16adec7dd..14efea1b6396d7f8e4f048e11e0decb9c1723469 100644 >--- a/Tools/ChangeLog >+++ b/Tools/ChangeLog >@@ -1,3 +1,12 @@ >+2019-02-10 Darin Adler <darin@apple.com> >+ >+ 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 NOBODY (OOPS!). >+ >+ * WebKitTestRunner/TestController.cpp: Removed unnecessary include of HexNumber.h. >+ > 2019-02-09 Benjamin Poulain <benjamin@webkit.org> > > Add more tests for clampTo<>() >diff --git a/Tools/WebKitTestRunner/TestController.cpp b/Tools/WebKitTestRunner/TestController.cpp >index 4cc4cccc0f023876de4a00dab367ec8c681ac29b..8055efc1a3dfe151ea14821229e8e9cb0a0839a4 100644 >--- a/Tools/WebKitTestRunner/TestController.cpp >+++ b/Tools/WebKitTestRunner/TestController.cpp >@@ -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>
You cannot view the attachment while viewing its details because your browser does not support IFRAMEs.
View the attachment on a separate page
.
View Attachment As Diff
View Attachment As Raw
Actions:
View
|
Formatted Diff
|
Diff
Attachments on
bug 194485
:
361649
|
361650