[webkit-changes] [WebKit/WebKit] 985e10: atob() clones the output more than necessary
Keith Miller
noreply at github.com
Wed Jul 12 17:17:56 PDT 2023
Branch: refs/heads/main
Home: https://github.com/WebKit/WebKit
Commit: 985e10033996f84d82cced3fb13023988cbb606f
https://github.com/WebKit/WebKit/commit/985e10033996f84d82cced3fb13023988cbb606f
Author: Keith Miller <keith_miller at apple.com>
Date: 2023-07-12 (Wed, 12 Jul 2023)
Changed paths:
M JSTests/stress/atob-btoa.js
M Source/JavaScriptCore/jsc.cpp
M Source/WTF/wtf/text/Base64.cpp
M Source/WTF/wtf/text/Base64.h
M Source/WTF/wtf/text/WTFString.h
M Source/WebCore/page/Base64Utilities.cpp
M Source/WebCore/page/Page.cpp
Log Message:
-----------
atob() clones the output more than necessary
https://bugs.webkit.org/show_bug.cgi?id=258789
rdar://111993365
Reviewed by David Kilzer.
Right now several users of `base64Decode` take the `Vector` returned and immediately convert it to a `String`. This
conversion requires a copy as the `Vector` returned by `base64Decode` uses `VectorBufferMalloc` but `String` requires
that the Vector backing store is malloced with `StringImplMalloc`. This patch simply adds a `base64DecodeToString` that
calls `base64DecodeInternal` with a new template parameter telling `base64DecodeInternal` to use `StringImplMalloc`. Thus,
avoiding the extra string copy.
* Source/JavaScriptCore/jsc.cpp:
(JSC_DEFINE_HOST_FUNCTION):
* Source/WTF/wtf/text/Base64.cpp:
(WTF::base64DecodeInternal):
(WTF::base64DecodeToString):
* Source/WTF/wtf/text/Base64.h:
* Source/WTF/wtf/text/WTFString.h:
* Source/WebCore/page/Base64Utilities.cpp:
(WebCore::Base64Utilities::atob):
* Source/WebCore/page/Page.cpp:
(WebCore::Page::userStyleSheetLocationChanged):
Canonical link: https://commits.webkit.org/266016@main
More information about the webkit-changes
mailing list