From 1c350bcf07a7a3a5df8e4b8d95b1321baaec22c6 Mon Sep 17 00:00:00 2001 From: terencehill Date: Fri, 17 Mar 2023 19:15:50 +0100 Subject: [PATCH] Refactor IL_CLEAR to avoid using IL_EACH which is now incompatible with it. As bonus the expanded code of IL_CLEAR is now simpler and optimized --- qcsrc/lib/intrusivelist.qh | 16 +++++++++++----- 1 file changed, 11 insertions(+), 5 deletions(-) diff --git a/qcsrc/lib/intrusivelist.qh b/qcsrc/lib/intrusivelist.qh index 7c4728a32..c328a6032 100644 --- a/qcsrc/lib/intrusivelist.qh +++ b/qcsrc/lib/intrusivelist.qh @@ -153,11 +153,17 @@ void IL_REMOVE(IntrusiveList this, entity it) */ #define IL_CLEAR(this) \ MACRO_BEGIN \ - IntrusiveList __il = this; \ - assert(__il); \ - .entity il_prev = __il.il_prevfld; \ - IL_EACH(__il, true, it.(il_next) = it.(il_prev) = NULL); \ - __il.il_head = __il.il_tail = NULL; \ + IntrusiveList _il = this; \ + assert(_il); \ + .entity il_prev = _il.il_prevfld; \ + .entity il_next = _il.il_nextfld; \ + noref int i = 0; \ + for (entity _next, _it = _il.il_head; _it; (_it = _next, ++i)) \ + { \ + _next = _it.(il_next); \ + _it.(il_next) = _it.(il_prev) = NULL; \ + } \ + _il.il_head = _il.il_tail = NULL; \ MACRO_END /** -- 2.39.2