diff options
author | halcanary <halcanary@google.com> | 2016-05-23 09:11:58 -0700 |
---|---|---|
committer | Commit bot <commit-bot@chromium.org> | 2016-05-23 09:11:59 -0700 |
commit | a0af771612db5ae36b74f1f536bfb335ecd0ec99 (patch) | |
tree | 5bce33c400039d9a5a39d08269dd574e69858735 /include/core | |
parent | f0270c32c1c4024f60788265518fec103de4b4eb (diff) |
SkTypes: use constexpr when appropriate
motivation: https://codereview.chromium.org/2000853003
GOLD_TRYBOT_URL= https://gold.skia.org/search?issue=2004073002
Review-Url: https://codereview.chromium.org/2004073002
Diffstat (limited to 'include/core')
-rw-r--r-- | include/core/SkTypes.h | 8 |
1 files changed, 4 insertions, 4 deletions
diff --git a/include/core/SkTypes.h b/include/core/SkTypes.h index 6793e4c0fb..13b662abf6 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); } |