diff options
author | Hal Canary <halcanary@google.com> | 2017-04-17 16:30:06 -0400 |
---|---|---|
committer | Skia Commit-Bot <skia-commit-bot@chromium.org> | 2017-05-04 13:08:29 +0000 |
commit | 5c1b360a89f85accd7dc446670f6f062c73e7e77 (patch) | |
tree | a15f476b39778027f982d753719487bc4a6d34ca /src/pdf/SkPDFUtils.h | |
parent | bc6e5ff7cfbacc28659c0aecbe9f2989cad80336 (diff) |
src/pdf: code cleanup
* SkPDFCanon: remove unnecessary abstraction
* Make use of SkTHashMap<K, sk_sp<T>>.
* Remove unncessary struct constructors.
* More factory fns return sk_sp<T>
* SkPDFUtility::GetCachedT<T> factored out.
Change-Id: I4055a131b43fe2588fd042b769cd09fff8a3466c
Reviewed-on: https://skia-review.googlesource.com/13655
Reviewed-by: Ben Wagner <bungeman@google.com>
Commit-Queue: Hal Canary <halcanary@google.com>
Diffstat (limited to 'src/pdf/SkPDFUtils.h')
-rw-r--r-- | src/pdf/SkPDFUtils.h | 9 |
1 files changed, 9 insertions, 0 deletions
diff --git a/src/pdf/SkPDFUtils.h b/src/pdf/SkPDFUtils.h index 5c9e46b381..00c4b72b7b 100644 --- a/src/pdf/SkPDFUtils.h +++ b/src/pdf/SkPDFUtils.h @@ -102,6 +102,15 @@ inline void WriteUTF16beHex(SkDynamicMemoryWStream* wStream, SkUnichar utf32) { SkPDFUtils::WriteUInt16BE(wStream, utf16[1]); } } + +template <class T> +static sk_sp<T> GetCachedT(sk_sp<T>* cachedT, sk_sp<T> (*makeNewT)()) { + if (*cachedT) { + return *cachedT; + } + *cachedT = (*makeNewT)(); + return *cachedT; +} } // namespace SkPDFUtils #endif |