From 4911e129f8b370b47f0b7c4f5e5b3256ac5366f1 Mon Sep 17 00:00:00 2001 From: Geoffrey McRae Date: Sun, 19 Nov 2023 16:31:45 +1100 Subject: [PATCH] [common] time: improve flow with compiler hints --- common/include/common/time.h | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/common/include/common/time.h b/common/include/common/time.h index 38c320f0..9e9be15b 100644 --- a/common/include/common/time.h +++ b/common/include/common/time.h @@ -23,6 +23,7 @@ #include #include #include +#include "common/util.h" #if defined(_WIN32) #include @@ -40,7 +41,7 @@ static inline uint64_t microtime(void) { #if defined(_WIN32) static unsigned long div = 0; - if (div == 0) + if (unlikely(div == 0)) { LARGE_INTEGER freq = { .QuadPart = 0LL }; QueryPerformanceFrequency(&freq); @@ -78,7 +79,7 @@ static inline uint64_t nanotime(void) { #if defined(_WIN32) static double multiplier = 0.0; - if (!multiplier) + if (unlikely(!multiplier)) { LARGE_INTEGER freq = { .QuadPart = 0LL }; QueryPerformanceFrequency(&freq);