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

Unified Diff: src/core/SkStream.cpp

Issue 565803005: use SkData::NewUninitialized (Closed) Base URL: https://skia.googlesource.com/skia.git@master
Patch Set: readInData -> NewFromStream 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 | « src/core/SkPictureData.cpp ('k') | src/images/SkDecodingImageGenerator.cpp » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: src/core/SkStream.cpp
diff --git a/src/core/SkStream.cpp b/src/core/SkStream.cpp
index e290b2158099593376ac57ee7839136dea11ffc6..ff14a8b26f5606bbd576043e6729349bdbdcaf43 100644
--- a/src/core/SkStream.cpp
+++ b/src/core/SkStream.cpp
@@ -869,13 +869,7 @@ SkData* SkCopyStreamToData(SkStream* stream) {
SkASSERT(stream != NULL);
if (stream->hasLength()) {
- const size_t length = stream->getLength();
- SkData* data = SkData::NewUninitialized(length);
- if (stream->read(data->writable_data(), length) != length) {
- data->unref();
- data = NULL;
- }
- return data;
+ return SkData::NewFromStream(stream, stream->getLength());
}
SkDynamicMemoryWStream tempStream;
@@ -902,9 +896,7 @@ SkStreamRewindable* SkStreamRewindableFromSkStream(SkStream* stream) {
if (stream->hasPosition()) { // If stream has length, but can't rewind.
length -= stream->getPosition();
}
- SkAutoTUnref<SkData> data(SkData::NewUninitialized(length));
- SkDEBUGCODE(size_t read =) stream->read(data->writable_data(), length);
- SkASSERT(length == read);
+ SkAutoTUnref<SkData> data(SkData::NewFromStream(stream, length));
return SkNEW_ARGS(SkMemoryStream, (data.get()));
}
SkDynamicMemoryWStream tempStream;
« no previous file with comments | « src/core/SkPictureData.cpp ('k') | src/images/SkDecodingImageGenerator.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698