From 7de18e5c7b4e4a8ad8910b1016688ded902f185b Mon Sep 17 00:00:00 2001 From: "bungeman@google.com" Date: Mon, 4 Feb 2013 15:58:08 +0000 Subject: [PATCH] Add sk_ignore_unused_variable to avoid warnings. https://codereview.appspot.com/7218045/ git-svn-id: http://skia.googlecode.com/svn/trunk@7539 2bbb7eff-a529-9590-31e7-b0007b416f81 --- bench/ChecksumBench.cpp | 11 ++++------- include/core/SkTemplates.h | 6 ++++++ 2 files changed, 10 insertions(+), 7 deletions(-) diff --git a/bench/ChecksumBench.cpp b/bench/ChecksumBench.cpp index 4158d94ec1..8226ddd322 100644 --- a/bench/ChecksumBench.cpp +++ b/bench/ChecksumBench.cpp @@ -11,8 +11,7 @@ #include "SkMD5.h" #include "SkRandom.h" #include "SkSHA1.h" - -template inline void sk_ignore_unused(const T&) { } +#include "SkTemplates.h" enum ChecksumType { kChecksum_ChecksumType, @@ -57,7 +56,7 @@ protected: case kChecksum_ChecksumType: { for (int i = 0; i < N; i++) { volatile uint32_t result = SkChecksum::Compute(fData, sizeof(fData)); - sk_ignore_unused(result); + sk_ignore_unused_variable(result); } } break; case kMD5_ChecksumType: { @@ -66,7 +65,6 @@ protected: md5.update(reinterpret_cast(fData), sizeof(fData)); SkMD5::Digest digest; md5.finish(digest); - sk_ignore_unused(digest); } } break; case kSHA1_ChecksumType: { @@ -75,19 +73,18 @@ protected: sha1.update(reinterpret_cast(fData), sizeof(fData)); SkSHA1::Digest digest; sha1.finish(digest); - sk_ignore_unused(digest); } } break; case kCityHash32: { for (int i = 0; i < N; i++) { volatile uint32_t result = SkCityHash::Compute32(reinterpret_cast(fData), sizeof(fData)); - sk_ignore_unused(result); + sk_ignore_unused_variable(result); } } break; case kCityHash64: { for (int i = 0; i < N; i++) { volatile uint64_t result = SkCityHash::Compute64(reinterpret_cast(fData), sizeof(fData)); - sk_ignore_unused(result); + sk_ignore_unused_variable(result); } } break; } diff --git a/include/core/SkTemplates.h b/include/core/SkTemplates.h index 42e9943dec..c4ba0e676a 100644 --- a/include/core/SkTemplates.h +++ b/include/core/SkTemplates.h @@ -19,6 +19,12 @@ resource management. */ +/** + * Marks a local variable as known to be unused (to avoid warnings). + * Note that this does *not* prevent the local variable from being optimized away. + */ +template inline void sk_ignore_unused_variable(const T&) { } + /** * SkTIsConst::value is true if the type T is const. * The type T is constrained not to be an array or reference type.