Bug 226304 - Leverage the new Vector(const T*, size_t) constructor
Summary: Leverage the new Vector(const T*, size_t) constructor
Status: RESOLVED FIXED
Alias: None
Product: WebKit
Classification: Unclassified
Component: Web Template Framework (show other bugs)
Version: WebKit Nightly Build
Hardware: Unspecified Unspecified
: P2 Normal
Assignee: Chris Dumez
URL:
Keywords: InRadar
Depends on:
Blocks:
 
Reported: 2021-05-26 16:08 PDT by Chris Dumez
Modified: 2021-05-26 20:18 PDT (History)
34 users (show)

See Also:


Attachments
Patch (39.84 KB, patch)
2021-05-26 16:10 PDT, Chris Dumez
ews-feeder: commit-queue-
Details | Formatted Diff | Diff
Patch (39.87 KB, patch)
2021-05-26 16:31 PDT, Chris Dumez
ews-feeder: commit-queue-
Details | Formatted Diff | Diff
Patch (45.06 KB, patch)
2021-05-26 18:47 PDT, Chris Dumez
ews-feeder: commit-queue-
Details | Formatted Diff | Diff
Patch (44.91 KB, patch)
2021-05-26 18:56 PDT, Chris Dumez
ews-feeder: commit-queue-
Details | Formatted Diff | Diff
Patch (45.01 KB, patch)
2021-05-26 19:16 PDT, Chris Dumez
no flags Details | Formatted Diff | Diff

Note You need to log in before you can comment on or make changes to this bug.
Description Chris Dumez 2021-05-26 16:08:38 PDT
Leverage the new Vector(const T*, size_t) constructor in existing code.
Comment 1 Chris Dumez 2021-05-26 16:10:58 PDT
Created attachment 429809 [details]
Patch
Comment 2 EWS Watchlist 2021-05-26 16:11:38 PDT
Thanks for the patch. If this patch contains new public API please make sure it follows the guidelines for new WebKit2 GTK+ API. See https://trac.webkit.org/wiki/WebKitGTK/AddingNewWebKit2API
Comment 3 Chris Dumez 2021-05-26 16:31:39 PDT
Created attachment 429812 [details]
Patch
Comment 4 Darin Adler 2021-05-26 18:08:16 PDT
Comment on attachment 429812 [details]
Patch

View in context: https://bugs.webkit.org/attachment.cgi?id=429812&action=review

> Source/WebCore/Modules/fetch/FetchBodyConsumer.cpp:47
> +    Vector<uint8_t> value { data, length };
>      return Blob::create(context, WTFMove(value), Blob::normalizedContentType(contentType));

Maybe merge this into a single line. We can omit the WTFMove so it won’t necessarily be a super-long line.

> Source/WebCore/Modules/indexeddb/IDBGetResult.cpp:38
> +    Vector<uint8_t> data { reinterpret_cast<const uint8_t*>(buffer.data()), buffer.size() };
>      m_value = ThreadSafeDataBuffer::create(WTFMove(data));

Ditto. Also use dataAsUInt8Ptr() to avoid the reinterpret_cast.

> Source/WebCore/Modules/webauthn/fido/FidoHidPacket.cpp:123
> +    Vector<uint8_t> data = { serialized.begin() + index, dataSize };

No need for the "=" here.

> Source/WebCore/crypto/mac/SerializedCryptoKeyWrapMac.mm:65
>  inline Vector<uint8_t> vectorFromNSData(NSData* data)

Surprised that this is the only place this function is needed.

Also, should be marked static since it’s intended to have internal linkage.

> Source/WebCore/fileapi/Blob.cpp:117
> +    blobParts.append(BlobPart(Vector<uint8_t> { reinterpret_cast<const uint8_t*>(buffer.data()), buffer.size() }));

Use dataAsUInt8Ptr() to avoid the reinterpret_cast.

> Source/WebKit/UIProcess/API/Cocoa/_WKWebAuthenticationPanel.mm:296
>  static Vector<uint8_t> vectorFromNSData(NSData* data)

Here it is, another copy of the same function as in SerializedCryptoKeyWrapMac.mm. With the same name.

> Source/WebKit/UIProcess/Cocoa/SOAuthorization/SubFrameSOAuthorizationSession.mm:46
>  static inline Vector<uint8_t> convertBytesToVector(const uint8_t byteArray[], const size_t length)

Don’t really need a function for this any more. Could just put the braces down below.

> Source/WebKit/UIProcess/WebAuthentication/Cocoa/LocalAuthenticator.mm:91
>  static inline Vector<uint8_t> toVector(NSData *data)

A third copy of the same function as in SerializedCryptoKeyWrapMac.mm. This time with a different name.

> Source/WebKit/UIProcess/WebAuthentication/Cocoa/NfcConnection.mm:95
> +    return { reinterpret_cast<const uint8_t*>(responseData.bytes), responseData.length };

This could use one of those many "convert NSData to Vector" functions.

> Source/WebKit/UIProcess/WebURLSchemeTask.cpp:224
> +            data = { reinterpret_cast<const uint8_t*>(m_syncData->data()), m_syncData->size() };

Use dataAsUInt8Ptr() to avoid the reinterpret_cast.
Comment 5 Chris Dumez 2021-05-26 18:47:19 PDT
Created attachment 429823 [details]
Patch
Comment 6 Chris Dumez 2021-05-26 18:56:24 PDT
Created attachment 429825 [details]
Patch
Comment 7 Chris Dumez 2021-05-26 19:16:19 PDT
Created attachment 429827 [details]
Patch
Comment 8 EWS 2021-05-26 20:17:35 PDT
Committed r278146 (238190@main): <https://commits.webkit.org/238190@main>

All reviewed patches have been landed. Closing bug and clearing flags on attachment 429827 [details].
Comment 9 Radar WebKit Bug Importer 2021-05-26 20:18:22 PDT
<rdar://problem/78548298>