Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(9)

Unified Diff: include/core/SkTypes.h

Issue 2004073002: SkTypes: use constexpr when appropriate (Closed) Base URL: https://skia.googlesource.com/skia.git@master
Patch Set: 2016-05-23 (Monday) 11:56:10 EDT Created 4 years, 7 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « no previous file | tests/CPlusPlusEleven.cpp » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: include/core/SkTypes.h
diff --git a/include/core/SkTypes.h b/include/core/SkTypes.h
index 6793e4c0fbba82d02855fa0bcdfebcead3b836d0..13b662abf66cd05e815e58f4563815c19b8d559b 100644
--- a/include/core/SkTypes.h
+++ b/include/core/SkTypes.h
@@ -369,7 +369,7 @@ typedef uint32_t SkMSec;
/** Faster than SkToBool for integral conditions. Returns 0 or 1
*/
-static inline int Sk32ToBool(uint32_t n) {
+static constexpr int Sk32ToBool(uint32_t n) {
return (n | (0-n)) >> 31;
}
@@ -408,11 +408,11 @@ static inline int32_t SkMin32(int32_t a, int32_t b) {
return a;
}
-template <typename T> const T& SkTMin(const T& a, const T& b) {
+template <typename T> constexpr const T& SkTMin(const T& a, const T& b) {
return (a < b) ? a : b;
}
-template <typename T> const T& SkTMax(const T& a, const T& b) {
+template <typename T> constexpr const T& SkTMax(const T& a, const T& b) {
return (b < a) ? a : b;
}
@@ -428,7 +428,7 @@ static inline int32_t SkFastMin32(int32_t value, int32_t max) {
}
/** Returns value pinned between min and max, inclusively. */
-template <typename T> static inline const T& SkTPin(const T& value, const T& min, const T& max) {
+template <typename T> static constexpr const T& SkTPin(const T& value, const T& min, const T& max) {
return SkTMax(SkTMin(value, max), min);
}
« no previous file with comments | « no previous file | tests/CPlusPlusEleven.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698