Bug 236749

Summary: Unnecessary copy/memory allocation
Product: WebKit Reporter: Jean-Yves Avenard [:jya] <jean-yves.avenard>
Component: Page LoadingAssignee: Jean-Yves Avenard [:jya] <jean-yves.avenard>
Status: RESOLVED FIXED    
Severity: Normal CC: beidson, dino, webkit-bug-importer
Priority: P2 Keywords: InRadar
Version: Other   
Hardware: Unspecified   
OS: Unspecified   
Attachments:
Description Flags
Patch none

Jean-Yves Avenard [:jya]
Reported 2022-02-16 20:21:00 PST
We see: Source/WebKitLegacy/mac/WebView/WebHTMLView.mm https://github.com/WebKit/WebKit/blob/f0427c65db487c75295c5bd757777cb5d9049030/Source/WebKitLegacy/mac/WebView/WebHTMLView.mm#L3544-L3547 ``` if (auto* image = hitTestResult.image()) { if (RefPtr<WebCore::FragmentedSharedBuffer> buffer = image->data()) [items addObject:adoptNS([[NSImage alloc] initWithData:[NSData dataWithBytes:buffer->makeContiguous()->data() length:buffer->size()]]).get()]; } ``` we can create a NSData from the SharedBuffer directly, removing the need for the memory allocation and copy.
Attachments
Patch (1.73 KB, patch)
2022-02-16 20:39 PST, Jean-Yves Avenard [:jya]
no flags
Radar WebKit Bug Importer
Comment 1 2022-02-16 20:21:50 PST
Jean-Yves Avenard [:jya]
Comment 2 2022-02-16 20:39:01 PST
EWS
Comment 3 2022-02-17 15:27:03 PST
Committed r290082 (247438@main): <https://commits.webkit.org/247438@main> All reviewed patches have been landed. Closing bug and clearing flags on attachment 452300 [details].
Note You need to log in before you can comment on or make changes to this bug.