From: terencehill Date: Fri, 17 Mar 2023 18:15:50 +0000 (+0100) Subject: Refactor IL_CLEAR to avoid using IL_EACH which is now incompatible with it. As bonus... X-Git-Tag: xonotic-v0.8.6~141^2~5 X-Git-Url: https://git.rm.cloudns.org/?a=commitdiff_plain;h=1c350bcf07a7a3a5df8e4b8d95b1321baaec22c6;p=xonotic%2Fxonotic-data.pk3dir.git 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 --- 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 /**