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
diff --git a/bench/ChecksumBench.cpp b/bench/ChecksumBench.cpp
index 4158d94..8226ddd 100644
--- a/bench/ChecksumBench.cpp
+++ b/bench/ChecksumBench.cpp
@@ -11,8 +11,7 @@
#include "SkMD5.h"
#include "SkRandom.h"
#include "SkSHA1.h"
-
-template<typename T> inline void sk_ignore_unused(const T&) { }
+#include "SkTemplates.h"
enum ChecksumType {
kChecksum_ChecksumType,
@@ -57,7 +56,7 @@
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 @@
md5.update(reinterpret_cast<uint8_t*>(fData), sizeof(fData));
SkMD5::Digest digest;
md5.finish(digest);
- sk_ignore_unused(digest);
}
} break;
case kSHA1_ChecksumType: {
@@ -75,19 +73,18 @@
sha1.update(reinterpret_cast<uint8_t*>(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<char*>(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<char*>(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 42e9943..c4ba0e6 100644
--- a/include/core/SkTemplates.h
+++ b/include/core/SkTemplates.h
@@ -20,6 +20,12 @@
*/
/**
+ * 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<typename T> inline void sk_ignore_unused_variable(const T&) { }
+
+/**
* SkTIsConst<T>::value is true if the type T is const.
* The type T is constrained not to be an array or reference type.
*/