haikuwebkit/Source/WebCore/Modules/async-clipboard
Chris Dumez 044109e09d Fix some inefficient uses of SharedBuffer
https://bugs.webkit.org/show_bug.cgi?id=226857

Reviewed by Darin Adler.

Fix some inefficient uses of SharedBuffer:
- Avoid calling SharedBuffer::data() whenever possible since this function
  may have to combine internal segments of SharedBuffer. Added a convenience
  function on SharedBuffer (forEachSegment()) to get the data pointer / size
  of each segment.
- Avoid some unnecessary construction of SharedBuffer simply to get a Vector.
  We should construct the Vector directly in such cases. I dropped the
  Blob factory that took in a SharedBuffer as it was inefficient and frequently
  called instead of the more efficient factory that takes in a Vector<uint8_t>.
- Add convenience functions to SharedBuffer that return a Vector, including one
  named takeData() that avoids copying the data.
- Add convenience functions to SharedBuffer for doing a prefix check or copying
  to a destination pointer.

* Modules/async-clipboard/ClipboardItem.cpp:
(WebCore::ClipboardItem::blobFromString):
* Modules/async-clipboard/ios/ClipboardImageReaderIOS.mm:
(WebCore::ClipboardImageReader::readBuffer):
* Modules/async-clipboard/mac/ClipboardImageReaderMac.mm:
(WebCore::ClipboardImageReader::readBuffer):
* Modules/fetch/FetchBodyConsumer.cpp:
(WebCore::blobFromData):
(WebCore::packageFormData):
(WebCore::resolveWithTypeAndData):
(WebCore::FetchBodyConsumer::takeAsBlob):
* Modules/indexeddb/IDBGetResult.cpp:
* Modules/indexeddb/IDBGetResult.h:
* Modules/mediarecorder/MediaRecorder.cpp:
(WebCore::createDataAvailableEvent):
* Modules/mediastream/RTCDataChannel.cpp:
(WebCore::RTCDataChannel::didReceiveRawData):
* editing/WebCorePasteboardFileReader.cpp:
(WebCore::WebCorePasteboardFileReader::readBuffer):
* editing/cocoa/WebContentReaderCocoa.mm:
(WebCore::createFragmentForImageAttachment):
(WebCore::replaceRichContentWithAttachments):
(WebCore::createFragmentAndAddResources):
(WebCore::sanitizeMarkupWithArchive):
(WebCore::WebContentReader::readImage):
(WebCore::attachmentForData):
* editing/gtk/WebContentReaderGtk.cpp:
(WebCore::WebContentReader::readImage):
* fileapi/Blob.cpp:
* fileapi/Blob.h:
* fileapi/NetworkSendQueue.cpp:
(WebCore::NetworkSendQueue::processMessages):
* html/HTMLAttachmentElement.cpp:
(WebCore::HTMLAttachmentElement::updateEnclosingImageWithData):
* inspector/agents/InspectorNetworkAgent.cpp:
(WebCore::InspectorNetworkAgent::didReceiveResponse):
* loader/DocumentLoader.cpp:
(WebCore::DocumentLoader::continueAfterContentPolicy):
* loader/DocumentThreadableLoader.cpp:
(WebCore::DocumentThreadableLoader::didFinishLoading):
(WebCore::DocumentThreadableLoader::loadRequest):
* loader/NetscapePlugInStreamLoader.cpp:
(WebCore::NetscapePlugInStreamLoader::didReceiveDataOrBuffer):
* loader/ResourceCryptographicDigest.cpp:
(WebCore::cryptographicDigestForSharedBuffer):
* loader/ResourceCryptographicDigest.h:
* loader/SubresourceIntegrity.cpp:
(WebCore::matchIntegrityMetadata):
* loader/appcache/ApplicationCacheGroup.cpp:
(WebCore::ApplicationCacheGroup::didFinishLoadingManifest):
* loader/appcache/ApplicationCacheStorage.cpp:
(WebCore::ApplicationCacheStorage::writeDataToUniqueFileInDirectory):
* loader/cache/CachedRawResource.cpp:
(WebCore::CachedRawResource::didAddClient):
* loader/icon/IconLoader.cpp:
(WebCore::IconLoader::notifyFinished):
* platform/SharedBuffer.cpp:
(WebCore::combineSegmentsData):
(WebCore::SharedBuffer::combineIntoOneSegment const):
(WebCore::SharedBuffer::data const):
(WebCore::SharedBuffer::takeData):
(WebCore::SharedBuffer::toHexString const):
(WebCore::SharedBuffer::forEachSegment const):
(WebCore::SharedBuffer::startsWith const):
(WebCore::SharedBuffer::copyTo const):
* platform/SharedBuffer.h:
* platform/cf/SharedBufferCF.cpp:
(WebCore::SharedBuffer::createCFData const):
* platform/graphics/displaylists/DisplayListItemBuffer.cpp:
(WebCore::DisplayList::ItemBuffer::append):
* svg/graphics/SVGImage.cpp:
(WebCore::SVGImage::dataChanged):
* workers/ScriptBuffer.cpp:
(WebCore::ScriptBuffer::toString const):
* xml/XMLHttpRequest.cpp:
(WebCore::XMLHttpRequest::createResponseBlob):


Canonical link: https://commits.webkit.org/238674@main
git-svn-id: https://svn.webkit.org/repository/webkit/trunk@278702 268f45cc-cd09-0410-ab3c-d52691b4dbfc
2021-06-10 15:08:18 +00:00
..
ios Fix some inefficient uses of SharedBuffer 2021-06-10 15:08:18 +00:00
mac Fix some inefficient uses of SharedBuffer 2021-06-10 15:08:18 +00:00
Clipboard.cpp Remove WTF::Optional synonym for std::optional, using that class template directly instead 2021-05-30 16:11:40 +00:00
Clipboard.h Remove <wtf/Optional.h> 2021-06-02 06:45:51 +00:00
Clipboard.idl
ClipboardImageReader.cpp Non-unified build fixes, early September 2020 edition 2020-09-16 15:09:28 +00:00
ClipboardImageReader.h Non-unified build fixes, early September 2020 edition 2020-09-16 15:09:28 +00:00
ClipboardItem.cpp Fix some inefficient uses of SharedBuffer 2021-06-10 15:08:18 +00:00
ClipboardItem.h Remove WTF::Optional synonym for std::optional, using that class template directly instead 2021-05-30 16:11:40 +00:00
ClipboardItem.idl
ClipboardItemBindingsDataSource.cpp Remove WTF::Optional synonym for std::optional, using that class template directly instead 2021-05-30 16:11:40 +00:00
ClipboardItemBindingsDataSource.h Remove <wtf/Optional.h> 2021-06-02 06:45:51 +00:00
ClipboardItemDataSource.h Remove WTF::Optional synonym for std::optional, using that class template directly instead 2021-05-30 16:11:40 +00:00
ClipboardItemPasteboardDataSource.cpp Remove WTF::Optional synonym for std::optional, using that class template directly instead 2021-05-30 16:11:40 +00:00
ClipboardItemPasteboardDataSource.h Remove WTF::Optional synonym for std::optional, using that class template directly instead 2021-05-30 16:11:40 +00:00
Navigator+Clipboard.idl [WebIDL] Switch to new file name convention for partial interfaces 2020-09-23 00:20:14 +00:00
NavigatorClipboard.cpp
NavigatorClipboard.h