remove unused dynamicwstream.snapshotAsData()
Checking to invalidate this on every write() call has a measurable cost, so removing it both simplifies the class and speeds it up.
BUG=skia:
Change-Id: Idf0baa265c9a0b5d26d82fce948c61ed9b0810b1
Reviewed-on: https://skia-review.googlesource.com/6096
Reviewed-by: Ben Wagner <bungeman@google.com>
Reviewed-by: Mike Klein <mtklein@chromium.org>
Commit-Queue: Mike Reed <reed@google.com>
diff --git a/tests/PDFGlyphsToUnicodeTest.cpp b/tests/PDFGlyphsToUnicodeTest.cpp
index b3ee2d8..a256c93 100644
--- a/tests/PDFGlyphsToUnicodeTest.cpp
+++ b/tests/PDFGlyphsToUnicodeTest.cpp
@@ -15,14 +15,19 @@
static bool stream_equals(const SkDynamicMemoryWStream& stream, size_t offset,
const char* buffer, size_t len) {
- sk_sp<SkData> data = stream.snapshotAsData();
- if (offset + len > data->size()) {
- return false;
- }
if (len != strlen(buffer)) {
return false;
}
- return memcmp(data->bytes() + offset, buffer, len) == 0;
+
+ const size_t streamSize = stream.bytesWritten();
+
+ if (offset + len > streamSize) {
+ return false;
+ }
+
+ SkAutoTMalloc<char> data(streamSize);
+ stream.copyTo(data.get());
+ return memcmp(data.get() + offset, buffer, len) == 0;
}
DEF_TEST(SkPDF_ToUnicode, reporter) {