From c5cebc1d190865b250cb94e86403f51804735d51 Mon Sep 17 00:00:00 2001 From: nmzik Date: Thu, 17 Sep 2026 20:03:21 +0400 Subject: [PATCH] remove unused helpers and the -64 suffix --- src/common/debug.cpp | 4 -- src/common/debug.h | 1 - src/common/hash.h | 97 -------------------------- src/common/threads.cpp | 4 -- src/common/threads.h | 1 - src/common/timer.cpp | 17 ----- src/common/timer.h | 6 -- src/kernel/pthread.cpp | 4 +- src/main.cpp | 3 +- tests/ImeDialogTests.cpp | 16 ++--- tests/ShaderRecompilerComputeTests.cpp | 12 +--- 11 files changed, 12 insertions(+), 153 deletions(-) diff --git a/src/common/debug.cpp b/src/common/debug.cpp index c24a7478..12fa54de 100644 --- a/src/common/debug.cpp +++ b/src/common/debug.cpp @@ -24,8 +24,4 @@ std::string Debug::GetLinker() { #endif } -std::string Debug::GetBitness() { - return "64"; -} - } // namespace Common diff --git a/src/common/debug.h b/src/common/debug.h index a82bfac8..b419d387 100644 --- a/src/common/debug.h +++ b/src/common/debug.h @@ -10,7 +10,6 @@ namespace Common { namespace Debug { std::string GetCompiler(); std::string GetLinker(); -std::string GetBitness(); } // namespace Debug } // namespace Common diff --git a/src/common/hash.h b/src/common/hash.h index 085d6c47..17b3d7ea 100644 --- a/src/common/hash.h +++ b/src/common/hash.h @@ -54,103 +54,6 @@ inline uint32_t hash(const void* key, uint32_t key_len) { return hash; } -inline uint32_t hash8(uint8_t key) { - uint32_t hash = 0; - - uint8_t* ptr = &key; - - hash += ptr[0]; - hash += (hash << 10u); - hash ^= (hash >> 6u); - - hash += (hash << 3u); - hash ^= (hash >> 11u); - hash += (hash << 15u); - - return hash; -} - -inline uint32_t hash16(uint16_t key) { - uint32_t hash = 0; - - auto* ptr = reinterpret_cast(&key); - - hash += ptr[0]; - hash += (hash << 10u); - hash ^= (hash >> 6u); - hash += ptr[1]; - hash += (hash << 10u); - hash ^= (hash >> 6u); - - hash += (hash << 3u); - hash ^= (hash >> 11u); - hash += (hash << 15u); - - return hash; -} - -inline uint32_t hash32(uint32_t key) { - uint32_t hash = 0; - - auto* ptr = reinterpret_cast(&key); - - hash += ptr[0]; - hash += (hash << 10u); - hash ^= (hash >> 6u); - hash += ptr[1]; - hash += (hash << 10u); - hash ^= (hash >> 6u); - hash += ptr[2]; - hash += (hash << 10u); - hash ^= (hash >> 6u); - hash += ptr[3]; - hash += (hash << 10u); - hash ^= (hash >> 6u); - - hash += (hash << 3u); - hash ^= (hash >> 11u); - hash += (hash << 15u); - - return hash; -} - -inline uint32_t hash64(uint64_t key) { - uint32_t hash = 0; - - auto* ptr = reinterpret_cast(&key); - - hash += ptr[0]; - hash += (hash << 10u); - hash ^= (hash >> 6u); - hash += ptr[1]; - hash += (hash << 10u); - hash ^= (hash >> 6u); - hash += ptr[2]; - hash += (hash << 10u); - hash ^= (hash >> 6u); - hash += ptr[3]; - hash += (hash << 10u); - hash ^= (hash >> 6u); - hash += ptr[4]; - hash += (hash << 10u); - hash ^= (hash >> 6u); - hash += ptr[5]; - hash += (hash << 10u); - hash ^= (hash >> 6u); - hash += ptr[6]; - hash += (hash << 10u); - hash ^= (hash >> 6u); - hash += ptr[7]; - hash += (hash << 10u); - hash ^= (hash >> 6u); - - hash += (hash << 3u); - hash ^= (hash >> 11u); - hash += (hash << 15u); - - return hash; -} - } // namespace Common #endif /* KYTY_COMMON_HASH_H_ */ diff --git a/src/common/threads.cpp b/src/common/threads.cpp index 2fa2fc7c..db3f285f 100644 --- a/src/common/threads.cpp +++ b/src/common/threads.cpp @@ -253,10 +253,6 @@ void Thread::Detach() { m_thread->m_thread.detach(); } -void Thread::Sleep(uint32_t millis) { - std::this_thread::sleep_for(std::chrono::milliseconds(millis)); -} - void Thread::SleepMicro(uint32_t micros) { #ifdef KYTY_WIN_CS SleepHighResolution100ns(static_cast(micros) * 10); diff --git a/src/common/threads.h b/src/common/threads.h index d37aa144..5b04ab8c 100644 --- a/src/common/threads.h +++ b/src/common/threads.h @@ -31,7 +31,6 @@ public: // The id is unique and can't be reused by another thread. [[nodiscard]] int GetUniqueId() const; - static void Sleep(uint32_t millis); static void SleepMicro(uint32_t micros); static void SleepNano(uint64_t nanos); static bool IsMainThread(); diff --git a/src/common/timer.cpp b/src/common/timer.cpp index 683a1641..5972abec 100644 --- a/src/common/timer.cpp +++ b/src/common/timer.cpp @@ -62,23 +62,6 @@ double Timer::GetTimeS() const { return (static_cast(current_time - m_StartTime)) / static_cast(m_Frequency); } -// return time in ticks -uint64_t Timer::GetTicks() const { - if (m_is_paused) { - return (m_PauseTime - m_StartTime); - } - - uint64_t current_time = 0; - SysQueryPerformanceCounter(¤t_time); - - return (current_time - m_StartTime); -} - -// return ticks frequency -uint64_t Timer::GetFrequency() const { - return m_Frequency; -} - uint64_t Timer::QueryPerformanceFrequency() { uint64_t ret = 0; SysQueryPerformanceFrequency(&ret); diff --git a/src/common/timer.h b/src/common/timer.h index ac192a69..29345a0c 100644 --- a/src/common/timer.h +++ b/src/common/timer.h @@ -24,12 +24,6 @@ public: // return time in seconds [[nodiscard]] double GetTimeS() const; - // return time in ticks - [[nodiscard]] uint64_t GetTicks() const; - - // return ticks frequency - [[nodiscard]] uint64_t GetFrequency() const; - KYTY_CLASS_NO_COPY(Timer); [[nodiscard]] static uint64_t QueryPerformanceFrequency(); diff --git a/src/kernel/pthread.cpp b/src/kernel/pthread.cpp index a80fa00a..1c3dd849 100644 --- a/src/kernel/pthread.cpp +++ b/src/kernel/pthread.cpp @@ -149,7 +149,7 @@ static uint64_t KernelGetTscFrequencyNative() { } KernelReadTscNative(); - Common::Thread::Sleep(1); + std::this_thread::sleep_for(std::chrono::milliseconds(1)); KernelReadTscNative(); const auto host_start = Common::Timer::QueryPerformanceCounter(); @@ -993,7 +993,7 @@ static void FreeDetachedThreads(void* /*arg*/) { auto* pthread_pool = g_pthread_context->GetPthreadPool(); while (true) { - Common::Thread::Sleep(10000); + std::this_thread::sleep_for(std::chrono::milliseconds(10000)); pthread_pool->FreeDetachedThreads(); } } diff --git a/src/main.cpp b/src/main.cpp index 4868bb8d..81f37980 100644 --- a/src/main.cpp +++ b/src/main.cpp @@ -27,8 +27,7 @@ static std::string GetBuildString() { std::string type = "????"; #endif - std::string compiler = - Debug::GetCompiler() + "-" + Debug::GetLinker() + "-" + Debug::GetBitness(); + std::string compiler = Debug::GetCompiler() + "-" + Debug::GetLinker(); std::string str = fmt::format("{}, {}, ver = {}, git = {}, date = {}", type.c_str(), compiler.c_str(), diff --git a/tests/ImeDialogTests.cpp b/tests/ImeDialogTests.cpp index a66c276a..5242a4d8 100644 --- a/tests/ImeDialogTests.cpp +++ b/tests/ImeDialogTests.cpp @@ -17,8 +17,6 @@ namespace Ime = Libs::Dialog::ImeDialog; namespace { -constexpr int Error(uint32_t value) { return static_cast(value); } - int g_filter_calls = 0; int g_keyboard_filter_calls = 0; bool g_block_keyboard = false; @@ -110,7 +108,7 @@ void TestAcceptLifecycle() { auto param = MakeParam(text.data()); CHECK(Ime::ImeDialogInit(¶m, nullptr) == 0); CHECK(Ime::ImeDialogGetStatus() == static_cast(Ime::Status::Running)); - CHECK(Ime::ImeDialogInit(nullptr, nullptr) == Error(0x80bc0001)); + CHECK(Ime::ImeDialogInit(nullptr, nullptr) == static_cast(0x80bc0001)); Ime::HostSnapshot snapshot; CHECK(Ime::GetHostSnapshot(&snapshot)); @@ -154,16 +152,16 @@ void TestValidation() { std::array text{}; auto param = MakeParam(text.data()); param.reserved[0] = 1; - CHECK(Ime::ImeDialogInit(¶m, nullptr) == Error(0x80bc0032)); + CHECK(Ime::ImeDialogInit(¶m, nullptr) == static_cast(0x80bc0032)); param.reserved[0] = 0; param.max_text_length = Ime::IME_DIALOG_MAX_TEXT_LENGTH + 1; - CHECK(Ime::ImeDialogInit(¶m, nullptr) == Error(0x80bc0016)); - CHECK(Ime::ImeDialogGetResult(nullptr) == Error(0x80bc0107)); + CHECK(Ime::ImeDialogInit(¶m, nullptr) == static_cast(0x80bc0016)); + CHECK(Ime::ImeDialogGetResult(nullptr) == static_cast(0x80bc0107)); param = MakeParam(text.data()); Ime::ExtendedParam extended{}; extended.ext_keyboard_mode = 0x00000004; - CHECK(Ime::ImeDialogInit(¶m, &extended) == Error(0x80bc001c)); + CHECK(Ime::ImeDialogInit(¶m, &extended) == static_cast(0x80bc001c)); extended = {}; extended.option = 0x00000200; extended.disable_device = @@ -187,8 +185,8 @@ void TestFilteringAndInputPolicy() { CHECK(Ime::ImeDialogInit(¶m, nullptr) == 0); CHECK(Ime::ImeDialogGetStatus() == static_cast(Ime::Status::Running)); CHECK(g_filter_calls == 0); - CHECK(Ime::ImeDialogGetResult(nullptr) == Error(0x80bc0031)); - CHECK(Ime::ImeDialogTerm() == Error(0x80bc0106)); + CHECK(Ime::ImeDialogGetResult(nullptr) == static_cast(0x80bc0031)); + CHECK(Ime::ImeDialogTerm() == static_cast(0x80bc0106)); CHECK(g_filter_calls == 0); Ime::HostSnapshot snapshot; diff --git a/tests/ShaderRecompilerComputeTests.cpp b/tests/ShaderRecompilerComputeTests.cpp index 73b8c8aa..d08c1b2b 100644 --- a/tests/ShaderRecompilerComputeTests.cpp +++ b/tests/ShaderRecompilerComputeTests.cpp @@ -926,10 +926,6 @@ std::string Hex(u32 value) { return buffer; } -std::string VulkanResultName(vk::Result result) { - return vk::to_string(result); -} - [[noreturn]] void Fail(const char *shader_name, const char *stage, const std::string &message) { std::fprintf(stderr, "ShaderRecompilerComputeTests: %s failed at %s: %s\n", @@ -960,7 +956,7 @@ void RequireVk(const char *shader_name, const char *stage, vk::Result result, const char *action) { if (result != vk::Result::eSuccess) { Fail(shader_name, stage, - std::string(action) + " returned " + VulkanResultName(result)); + std::string(action) + " returned " + vk::to_string(result)); } } @@ -15597,15 +15593,11 @@ enum class CoverageClass { NeedsGraphicsStageCase, }; -bool IsCovered(const std::set &covered, ShaderOpcode opcode) { - return covered.find(opcode) != covered.end(); -} - CoverageClass ClassifyOpcode(ShaderOpcode opcode, const std::set &covered) { using ShaderRecompiler::Decoder::Opcode; - if (IsCovered(covered, opcode)) { + if (covered.contains(opcode)) { return CoverageClass::Covered; }