From d4c6911b170b37cb6058d2a4aa3bcf30fd56d0a7 Mon Sep 17 00:00:00 2001 From: Ethan Chan Date: Mon, 27 Jan 2025 19:34:26 -0800 Subject: [PATCH] Use attributes to minimize branch prediction misses --- src/api.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/api.cpp b/src/api.cpp index f6f9739..850bab7 100644 --- a/src/api.cpp +++ b/src/api.cpp @@ -107,7 +107,7 @@ DK_API uint64_t dyknow_size(const std::string& directory) { std::string filename = data.cFileName; - if ((filename == ".") || (filename == "..")) { + if ((filename == ".") || (filename == "..")) [[unlikely]] { continue; } @@ -400,7 +400,7 @@ DK_API bool taskkill(DWORD identifier, KillMethod method) { case KillMethod::WIN32_API: { HANDLE process = OpenProcess(PROCESS_TERMINATE, FALSE, identifier); - if (process) { + if (process) [[likely]] { // Bam, terminated! TerminateProcess(process, static_cast(-1)); // -1 is the exit code for the process - in this case,