Commit 5c88bd9d authored by reed@chromium.org's avatar reed@chromium.org

use SkData::NewUninitialized, cheaper than NewFromMalloc

BUG=

Review URL: https://codereview.chromium.org/565813002

git-svn-id: svn://svn.chromium.org/blink/trunk@181924 bbb929c8-8fbe-4397-9dbb-9b2b20218538
parent eaac9fc9
......@@ -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()
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment