[Webkit-unassigned] [Bug 258789] New: atob() clones the output more than necessary

bugzilla-daemon at webkit.org bugzilla-daemon at webkit.org
Sun Jul 2 20:04:29 PDT 2023


            Bug ID: 258789
           Summary: atob() clones the output more than necessary
           Product: WebKit
           Version: WebKit Nightly Build
          Hardware: Unspecified
                OS: Unspecified
            Status: NEW
          Severity: Normal
          Priority: P2
         Component: WebCore JavaScript
          Assignee: webkit-unassigned at lists.webkit.org
          Reporter: jarred at jarredsumner.com

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?

You are receiving this mail because:
You are the assignee for the bug.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.webkit.org/pipermail/webkit-unassigned/attachments/20230703/75aa5f87/attachment.htm>

More information about the webkit-unassigned mailing list