From 1926966d21b09fc901f305f1e0625129d3a879e3 Mon Sep 17 00:00:00 2001 From: Lioncash Date: Sun, 15 Mar 2020 19:34:41 -0400 Subject: [PATCH] CCharAnimTime: Make constructors constexpr where applicable These can be made constexpr to allow use at compile-time, given these only hold an enum and a floating point value. --- Runtime/Character/CCharAnimTime.cpp | 4 ---- Runtime/Character/CCharAnimTime.hpp | 11 +++++------ 2 files changed, 5 insertions(+), 10 deletions(-) diff --git a/Runtime/Character/CCharAnimTime.cpp b/Runtime/Character/CCharAnimTime.cpp index f64512ea7..6d3d0eea1 100644 --- a/Runtime/Character/CCharAnimTime.cpp +++ b/Runtime/Character/CCharAnimTime.cpp @@ -5,10 +5,6 @@ namespace urde { -CCharAnimTime CCharAnimTime::Infinity() { - return {EType::Infinity, 1.f}; -} - bool CCharAnimTime::EqualsZero() const { if (x4_type == EType::ZeroIncreasing || x4_type == EType::ZeroSteady || x4_type == EType::ZeroDecreasing) return true; diff --git a/Runtime/Character/CCharAnimTime.hpp b/Runtime/Character/CCharAnimTime.hpp index 3aed3e0e8..e28e36e7d 100644 --- a/Runtime/Character/CCharAnimTime.hpp +++ b/Runtime/Character/CCharAnimTime.hpp @@ -16,13 +16,12 @@ private: EType x4_type = EType::ZeroSteady; public: - CCharAnimTime() = default; - CCharAnimTime(CInputStream& in) : x0_time(in.readFloatBig()), x4_type(EType(in.readUint32Big())) {} - CCharAnimTime(float time) : x0_time(time), x4_type(x0_time != 0.f ? EType::NonZero : EType::ZeroSteady) {} + constexpr CCharAnimTime() = default; + constexpr CCharAnimTime(float time) : x0_time(time), x4_type(x0_time != 0.f ? EType::NonZero : EType::ZeroSteady) {} + constexpr CCharAnimTime(EType type, float t) : x0_time(t), x4_type(type) {} + explicit CCharAnimTime(CInputStream& in) : x0_time(in.readFloatBig()), x4_type(EType(in.readUint32Big())) {} - CCharAnimTime(EType type, const float& t) : x0_time(t), x4_type(type) {} - - static CCharAnimTime Infinity(); + static constexpr CCharAnimTime Infinity() { return {EType::Infinity, 1.0f}; } float GetSeconds() const { return x0_time; } bool EqualsZero() const;