Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(1870)

Unified Diff: Source/platform/SharedBuffer.cpp

Issue 565813002: use SkData::NewUninitialized, cheaper than NewFromMalloc (Closed) Base URL: https://chromium.googlesource.com/chromium/blink.git@master
Patch Set: Created 6 years, 3 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « no previous file | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: Source/platform/SharedBuffer.cpp
diff --git a/Source/platform/SharedBuffer.cpp b/Source/platform/SharedBuffer.cpp
index f6cf3dc50d0e9f6b4dff0f2da99192fdeadd1e54..6594e7a9997651a24686ef91301fa8b1ee85bfcd 100644
--- a/Source/platform/SharedBuffer.cpp
+++ b/Source/platform/SharedBuffer.cpp
@@ -386,7 +386,8 @@ PassRefPtr<ArrayBuffer> SharedBuffer::getAsArrayBuffer() const
PassRefPtr<SkData> SharedBuffer::getAsSkData() const
{
unsigned bufferLength = size();
- char* buffer = static_cast<char*>(sk_malloc_throw(bufferLength));
+ SkData* data = SkData::NewUninitialized(bufferLength);
+ char* buffer = static_cast<char*>(data->writable_data());
const char* segment = 0;
unsigned position = 0;
while (unsigned segmentSize = getSomeData(segment, position)) {
@@ -399,7 +400,7 @@ PassRefPtr<SkData> SharedBuffer::getAsSkData() const
// Don't return the incomplete SkData.
return nullptr;
}
- return adoptRef(SkData::NewFromMalloc(buffer, bufferLength));
+ return adoptRef(data);
}
bool SharedBuffer::lock()
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698