aboutsummaryrefslogtreecommitdiffhomepage
path: root/tests/PDFGlyphsToUnicodeTest.cpp
diff options
context:
space:
mode:
authorGravatar Mike Reed <reed@google.com>2016-12-15 13:02:33 -0500
committerGravatar Skia Commit-Bot <skia-commit-bot@chromium.org>2016-12-15 19:01:02 +0000
commit5adaf8bf24e7581104c41c868188602624e8ba86 (patch)
tree134e6d015f48fe1bbb246029494cd7cb2c741009 /tests/PDFGlyphsToUnicodeTest.cpp
parenteaef5493ca51ccc722f594ed21d331d40bffd14c (diff)
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>
Diffstat (limited to 'tests/PDFGlyphsToUnicodeTest.cpp')
-rw-r--r--tests/PDFGlyphsToUnicodeTest.cpp13
1 files changed, 9 insertions, 4 deletions
diff --git a/tests/PDFGlyphsToUnicodeTest.cpp b/tests/PDFGlyphsToUnicodeTest.cpp
index b3ee2d86f2..a256c93a8d 100644
--- a/tests/PDFGlyphsToUnicodeTest.cpp
+++ b/tests/PDFGlyphsToUnicodeTest.cpp
@@ -15,14 +15,19 @@ static const int kMaximumGlyphCount = SK_MaxU16 + 1;
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()) {
+ if (len != strlen(buffer)) {
return false;
}
- if (len != strlen(buffer)) {
+
+ const size_t streamSize = stream.bytesWritten();
+
+ if (offset + len > streamSize) {
return false;
}
- return memcmp(data->bytes() + offset, buffer, len) == 0;
+
+ SkAutoTMalloc<char> data(streamSize);
+ stream.copyTo(data.get());
+ return memcmp(data.get() + offset, buffer, len) == 0;
}
DEF_TEST(SkPDF_ToUnicode, reporter) {