From 1cc1c33a159b36e4c731f00e2c83f1140dd7c561 Mon Sep 17 00:00:00 2001 From: Morph <39850852+Morph1984@users.noreply.github.com> Date: Thu, 12 May 2022 00:23:23 -0400 Subject: [PATCH] common: Resolve C4267 warning on MSVC Also removes Timer::GetDoubleTime() as it is unused. --- src/common/alignment.h | 2 +- src/common/texture.cpp | 6 +++--- src/common/texture.h | 2 +- src/common/timer.cpp | 20 -------------------- src/common/timer.h | 1 - src/common/x64/xbyak_abi.h | 4 ++-- 6 files changed, 7 insertions(+), 28 deletions(-) diff --git a/src/common/alignment.h b/src/common/alignment.h index 64fafd2e8..15f981d73 100644 --- a/src/common/alignment.h +++ b/src/common/alignment.h @@ -10,7 +10,7 @@ namespace Common { template [[nodiscard]] constexpr T AlignUp(T value, std::size_t size) { static_assert(std::is_unsigned_v, "T must be an unsigned value."); - auto mod{value % size}; + auto mod{static_cast(value % size)}; value -= mod; return static_cast(mod == T{0} ? value : value + size); } diff --git a/src/common/texture.cpp b/src/common/texture.cpp index 2ec939288..75b6a2cee 100644 --- a/src/common/texture.cpp +++ b/src/common/texture.cpp @@ -8,10 +8,10 @@ #include "common/common_types.h" namespace Common { -void FlipRGBA8Texture(std::vector& tex, u64 width, u64 height) { +void FlipRGBA8Texture(std::vector& tex, u32 width, u32 height) { ASSERT(tex.size() == width * height * 4); - const u64 line_size = width * 4; - for (u64 line = 0; line < height / 2; line++) { + const u32 line_size = width * 4; + for (u32 line = 0; line < height / 2; line++) { const u32 offset_1 = line * line_size; const u32 offset_2 = (height - line - 1) * line_size; // Swap lines diff --git a/src/common/texture.h b/src/common/texture.h index 2de56bc09..de53433b4 100644 --- a/src/common/texture.h +++ b/src/common/texture.h @@ -8,5 +8,5 @@ #include "common/common_types.h" namespace Common { -void FlipRGBA8Texture(std::vector& tex, u64 width, u64 height); +void FlipRGBA8Texture(std::vector& tex, u32 width, u32 height); } diff --git a/src/common/timer.cpp b/src/common/timer.cpp index 50c859cca..7a4250246 100644 --- a/src/common/timer.cpp +++ b/src/common/timer.cpp @@ -137,24 +137,4 @@ std::string Timer::GetTimeFormatted() { return fmt::format("{}:{:03}", tmp, milliseconds); } -// Returns a timestamp with decimals for precise time comparisons -// ---------------- -double Timer::GetDoubleTime() { - // Get continuous timestamp - u64 TmpSeconds = static_cast(Common::Timer::GetTimeSinceJan1970().count()); - double ms = static_cast(GetTimeMs().count()) % 1000; - - // Remove a few years. We only really want enough seconds to make - // sure that we are detecting actual actions, perhaps 60 seconds is - // enough really, but I leave a year of seconds anyway, in case the - // user's clock is incorrect or something like that. - TmpSeconds = TmpSeconds - (38 * 365 * 24 * 60 * 60); - - // Make a smaller integer that fits in the double - u32 Seconds = static_cast(TmpSeconds); - double TmpTime = Seconds + ms; - - return TmpTime; -} - } // Namespace Common diff --git a/src/common/timer.h b/src/common/timer.h index 8894a143d..826e21a42 100644 --- a/src/common/timer.h +++ b/src/common/timer.h @@ -24,7 +24,6 @@ public: [[nodiscard]] static std::chrono::seconds GetTimeSinceJan1970(); [[nodiscard]] static std::chrono::seconds GetLocalTimeSinceJan1970(); - [[nodiscard]] static double GetDoubleTime(); [[nodiscard]] static std::string GetTimeFormatted(); [[nodiscard]] std::string GetTimeElapsedFormatted() const; diff --git a/src/common/x64/xbyak_abi.h b/src/common/x64/xbyak_abi.h index 0139db232..235952a1e 100644 --- a/src/common/x64/xbyak_abi.h +++ b/src/common/x64/xbyak_abi.h @@ -158,10 +158,10 @@ struct ABIFrameInfo { inline ABIFrameInfo ABI_CalculateFrameSize(std::bitset<32> regs, std::size_t rsp_alignment, std::size_t needed_frame_size) { - int count = (regs & ABI_ALL_GPRS).count(); + const auto count = (regs & ABI_ALL_GPRS).count(); rsp_alignment -= count * 8; std::size_t subtraction = 0; - int xmm_count = (regs & ABI_ALL_XMMS).count(); + const auto xmm_count = (regs & ABI_ALL_XMMS).count(); if (xmm_count) { // If we have any XMMs to save, we must align the stack here. subtraction = rsp_alignment & 0xF;