Bug 258789
Summary: | atob() clones the output more than necessary | ||
---|---|---|---|
Product: | WebKit | Reporter: | Jarred Sumner <jarred> |
Component: | WebCore JavaScript | Assignee: | Keith Miller <keith_miller> |
Status: | RESOLVED FIXED | ||
Severity: | Normal | CC: | cdumez, mark.lam, webkit-bug-importer, ysuzuki |
Priority: | P2 | Keywords: | InRadar |
Version: | WebKit Nightly Build | ||
Hardware: | Unspecified | ||
OS: | Unspecified |
Jarred Sumner
From: https://github.com/WebKit/WebKit/blob/de456d04c10080ce71f48d14b3a9d278854d5f8a/Source/WebCore/page/Base64Utilities.cpp#L53
auto decodedData = base64Decode(encodedString, Base64DecodeMode::DefaultValidatePaddingAndIgnoreWhitespace);
if (!decodedData)
return Exception { InvalidCharacterError };
return String(decodedData->data(), decodedData->size());
String(const char*, unsigned) calls StringImpl::create(reinterpret_cast<const LChar*>(ptr), length).
This is an extra clone, from the Vector<uint8_t> -> StringImpl. Seems like moving the Vector would also clone it.
Possible suggestions:
- base64Decode could have a template arg to use WTF::StringBuilder?
- Maybe there's a way using ExternalStringImpl?
Attachments | ||
---|---|---|
Add attachment proposed patch, testcase, etc. |
Radar WebKit Bug Importer
<rdar://problem/111993365>
Keith Miller
Pull request: https://github.com/WebKit/WebKit/pull/15781
EWS
Committed 266016@main (985e10033996): <https://commits.webkit.org/266016@main>
Reviewed commits have been landed. Closing PR #15781 and removing active labels.