Further simplify StringBuilder usage by standardizing hex formating to a single hex...
authorweinig@apple.com <weinig@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Mon, 6 Jan 2020 00:20:57 +0000 (00:20 +0000)
committerweinig@apple.com <weinig@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Mon, 6 Jan 2020 00:20:57 +0000 (00:20 +0000)
commit461baac88a4fc40832562e94706c0a3658444951
tree2b378644e2a0e2cef87665d37b5aa788bfbf9daa
parentf8f6704d9a4ca83dd93d678e62e86962480be15b
Further simplify StringBuilder usage by standardizing hex formating to a single hex() function
https://bugs.webkit.org/show_bug.cgi?id=205759

Reviewed by Dean Jackson.

Source/JavaScriptCore:

* heap/HeapSnapshotBuilder.cpp:
(JSC::HeapSnapshotBuilder::json):
* runtime/JSGlobalObjectFunctions.cpp:
(JSC::encode):
(JSC::globalFuncEscape):
Replace appendUnsignedAsHex() and appendByteAsHex() with append(hex()).

Source/WebCore:

* Modules/websockets/WebSocket.cpp:
(WebCore::encodeProtocolString):
* css/CSSMarkup.cpp:
(WebCore::serializeCharacterAsCodePoint):
* css/parser/CSSParserToken.cpp:
(WebCore::CSSParserToken::serialize const):
* platform/graphics/Color.cpp:
(WebCore::Color::serialized const):
* platform/graphics/gstreamer/MediaPlayerPrivateGStreamer.cpp:
(WebCore::MediaPlayerPrivateGStreamer::processMpegTsSection):
* platform/graphics/opengl/GraphicsContext3DOpenGLCommon.cpp:
(WebCore::generateHashedName):
* platform/network/curl/CurlCacheEntry.cpp:
(WebCore::CurlCacheEntry::generateBaseFilename):
* rendering/RenderTreeAsText.cpp:
(WebCore::quoteAndEscapeNonPrintables):
Replace appendByteAsHex()/appendUnsignedAsHex()/appendUnsignedAsHexFixedSize() with append(hex()).

* platform/network/FormDataBuilder.cpp:
(WebCore::FormDataBuilder::appendFormURLEncoded):
This was the last non-StringBuilder/makeString use of appendByteAsHex. Rather than keep appendByteAsHex
around, it is replaced with direct appends of the character buffer hex() produces.

Source/WebKit:

* UIProcess/DeviceIdHashSaltStorage.cpp:
(WebKit::DeviceIdHashSaltStorage::completeDeviceIdHashSaltForOriginCall):
* UIProcess/WebBackForwardList.cpp:
(WebKit::WebBackForwardList::loggingString):
Replace appendUnsignedAsHex() with append(hex()).

Source/WTF:

Removes appendByteAsHex, appendUnsignedAsHex and appendUnsignedAsHexFixedSize with the
following mappings:

    appendByteAsHex(value, builder, case)
      -> builder.append(hex(static_cast<unsigned char>(value), 2, case))
    appendUnsignedAsHex(value, builder, case)
      -> builder.append(hex(value, case))
    appendUnsignedAsHexFixedSize(value, builder, size, case)
      -> builder.append(hex(value, size, case))

Adds new API test for HexNumber.cpp

* wtf/HexNumber.h:
(WTF::appendByteAsHex): Deleted.
(WTF::appendUnsignedAsHex): Deleted.
(WTF::appendUnsignedAsHexFixedSize): Deleted.
Remove now unused helper functions.

* wtf/FileSystem.cpp:
(WTF::FileSystemImpl::encodeForFileName):
Replace appendByteAsHex with direct use of hex(x, 2). The static_cast is needed
since there was an implicit down cast when appendByteAsHex was used.

* wtf/Logger.cpp:
(WTF::Logger::LogSiteIdentifier::toString const):
(WTF::>::toString):
* wtf/UUID.cpp:
(WTF::createCanonicalUUIDString):
Replace appendUnsignedAsHex/appendUnsignedAsHexFixedSize with hex(). Use makeString()
rather StringBuilder to simplify things further.

* wtf/text/WTFString.cpp:
(asciiDebug):
Replace appendUnsignedAsHexFixedSize with append(hex()).

Tools:

* TestWebKitAPI/CMakeLists.txt:
* TestWebKitAPI/TestWebKitAPI.xcodeproj/project.pbxproj:
* TestWebKitAPI/Tests/WTF/HexNumber.cpp: Added.
Add testing for hex formatting of integers.

git-svn-id: https://svn.webkit.org/repository/webkit/trunk@254046 268f45cc-cd09-0410-ab3c-d52691b4dbfc
26 files changed:
Source/JavaScriptCore/ChangeLog
Source/JavaScriptCore/heap/HeapSnapshotBuilder.cpp
Source/JavaScriptCore/runtime/JSGlobalObjectFunctions.cpp
Source/WTF/ChangeLog
Source/WTF/wtf/FileSystem.cpp
Source/WTF/wtf/HexNumber.h
Source/WTF/wtf/Logger.cpp
Source/WTF/wtf/UUID.cpp
Source/WTF/wtf/text/WTFString.cpp
Source/WebCore/ChangeLog
Source/WebCore/Modules/websockets/WebSocket.cpp
Source/WebCore/css/CSSMarkup.cpp
Source/WebCore/css/parser/CSSParserToken.cpp
Source/WebCore/platform/graphics/Color.cpp
Source/WebCore/platform/graphics/gstreamer/MediaPlayerPrivateGStreamer.cpp
Source/WebCore/platform/graphics/opengl/GraphicsContext3DOpenGLCommon.cpp
Source/WebCore/platform/network/FormDataBuilder.cpp
Source/WebCore/platform/network/curl/CurlCacheEntry.cpp
Source/WebCore/rendering/RenderTreeAsText.cpp
Source/WebKit/ChangeLog
Source/WebKit/UIProcess/DeviceIdHashSaltStorage.cpp
Source/WebKit/UIProcess/WebBackForwardList.cpp
Tools/ChangeLog
Tools/TestWebKitAPI/CMakeLists.txt
Tools/TestWebKitAPI/TestWebKitAPI.xcodeproj/project.pbxproj
Tools/TestWebKitAPI/Tests/WTF/HexNumber.cpp [new file with mode: 0644]