From 864a9d933d15387d096f0e77c380ffad44f176d1 Mon Sep 17 00:00:00 2001 From: Deukhoofd Date: Sat, 25 Apr 2020 16:15:27 +0200 Subject: [PATCH] Inlined get stats from Creature. These are frequently called one line methods. --- src/Battling/Models/Creature.cpp | 12 ------------ src/Battling/Models/Creature.hpp | 12 ++++++++---- 2 files changed, 8 insertions(+), 16 deletions(-) diff --git a/src/Battling/Models/Creature.cpp b/src/Battling/Models/Creature.cpp index 7fcc807..3c64adc 100644 --- a/src/Battling/Models/Creature.cpp +++ b/src/Battling/Models/Creature.cpp @@ -60,18 +60,6 @@ bool Battling::Creature::ChangeStatBoost(Library::Statistic stat, int8_t diffAmo return changed; } -uint32_t Battling::Creature::GetFlatStat(Library::Statistic stat) const noexcept { return _flatStats.GetStat(stat); } - -uint32_t Battling::Creature::GetBoostedStat(Library::Statistic stat) const noexcept { - return _boostedStats.GetStat(stat); -} - -uint32_t Battling::Creature::GetBaseStat(Library::Statistic stat) const noexcept { - return _variant->GetStatistic(stat); -} - -int8_t Battling::Creature::GetStatBoost(Library::Statistic stat) const noexcept { return _statBoost.GetStat(stat); } - void Battling::Creature::RecalculateFlatStats() { auto statCalc = this->_library->GetStatCalculator(); this->_flatStats = statCalc->CalculateFlatStats(this); diff --git a/src/Battling/Models/Creature.hpp b/src/Battling/Models/Creature.hpp index b6baa18..03bd054 100644 --- a/src/Battling/Models/Creature.hpp +++ b/src/Battling/Models/Creature.hpp @@ -142,10 +142,14 @@ namespace CreatureLib::Battling { // region Stat APIs bool ChangeStatBoost(Library::Statistic stat, int8_t diffAmount); - [[nodiscard]] uint32_t GetFlatStat(Library::Statistic stat) const noexcept; - [[nodiscard]] uint32_t GetBoostedStat(Library::Statistic stat) const noexcept; - [[nodiscard]] uint32_t GetBaseStat(Library::Statistic stat) const noexcept; - [[nodiscard]] int8_t GetStatBoost(Library::Statistic stat) const noexcept; + [[nodiscard]] inline uint32_t GetFlatStat(Library::Statistic stat) const { return _flatStats.GetStat(stat); } + [[nodiscard]] inline uint32_t GetBoostedStat(Library::Statistic stat) const { + return _boostedStats.GetStat(stat); + } + [[nodiscard]] inline uint32_t GetBaseStat(Library::Statistic stat) const { + return _variant->GetStatistic(stat); + } + [[nodiscard]] inline int8_t GetStatBoost(Library::Statistic stat) const { return _statBoost.GetStat(stat); } void RecalculateFlatStats(); void RecalculateBoostedStats(); void RecalculateFlatStat(Library::Statistic);