From 0bb83ed5e971f2f2d903cc4603b76e486a7abf86 Mon Sep 17 00:00:00 2001 From: Megamouse Date: Sat, 16 Nov 2024 13:05:07 +0100 Subject: [PATCH] Fix warning --- Utilities/lockless.h | 21 ++++++++++++--------- 1 file changed, 12 insertions(+), 9 deletions(-) diff --git a/Utilities/lockless.h b/Utilities/lockless.h index 95121e1084..7a25d2b25d 100644 --- a/Utilities/lockless.h +++ b/Utilities/lockless.h @@ -80,7 +80,7 @@ public: using return_t = decltype(func(std::declval())); - for (usz i = 0; _this; i += N) + while (_this) { for (usz j = 0; j < N; j++) { @@ -101,17 +101,20 @@ public: lf_array* next = m_next; - if (!next && !std::is_void_v && !is_finite) + if constexpr (!std::is_void_v) { - for (auto _new = new lf_array, ptr = _this; ptr;) + if (!next && !is_finite) { - // Install the pointer. If failed, go deeper. - ptr = ptr->m_next.compare_and_swap(nullptr, _new); - - if (!next) + for (auto _new = new lf_array, ptr = _this; ptr;) { - // Determine the next pointer (if null then the new memory has been installed) - next = ptr ? ptr : _new; + // Install the pointer. If failed, go deeper. + ptr = ptr->m_next.compare_and_swap(nullptr, _new); + + if (!next) + { + // Determine the next pointer (if null then the new memory has been installed) + next = ptr ? ptr : _new; + } } } }