From ceddb97bfdb8494a4fb87a3c8e08dbfcd6c10705 Mon Sep 17 00:00:00 2001 From: Jakob Rath Date: Wed, 30 Nov 2022 11:48:39 +0100 Subject: [PATCH] Disable asserts --- src/util/dlist.h | 14 ++++++++++---- 1 file changed, 10 insertions(+), 4 deletions(-) diff --git a/src/util/dlist.h b/src/util/dlist.h index 582af82d0..e5c95b8cf 100644 --- a/src/util/dlist.h +++ b/src/util/dlist.h @@ -21,6 +21,8 @@ Revision History: #include "util/debug.h" #include "util/util.h" +#define DLIST_EXTRA_ASSERTIONS 0 + template class dll_iterator; template @@ -58,7 +60,7 @@ public: } void insert_after(T* other) { -#ifndef NDEBUG +#if DLIST_EXTRA_ASSERTIONS SASSERT(other); SASSERT(invariant()); SASSERT(other->invariant()); @@ -74,7 +76,7 @@ public: other->m_prev = static_cast(this); other_end->m_next = next; next->m_prev = other_end; -#ifndef NDEBUG +#if DLIST_EXTRA_ASSERTIONS SASSERT(invariant()); SASSERT(other->invariant()); size_t const new_sz = count_if(*static_cast(this), [](T const&) { return true; }); @@ -83,7 +85,7 @@ public: } void insert_before(T* other) { -#ifndef NDEBUG +#if DLIST_EXTRA_ASSERTIONS SASSERT(other); SASSERT(invariant()); SASSERT(other->invariant()); @@ -99,7 +101,7 @@ public: other->m_prev = prev; other_end->m_next = static_cast(this); this->m_prev = other_end; -#ifndef NDEBUG +#if DLIST_EXTRA_ASSERTIONS SASSERT(invariant()); SASSERT(other->invariant()); size_t const new_sz = count_if(*static_cast(this), [](T const&) { return true; }); @@ -108,10 +110,12 @@ public: } static void remove_from(T*& list, T* elem) { +#if DLIST_EXTRA_ASSERTIONS SASSERT(list); SASSERT(elem); SASSERT(list->invariant()); SASSERT(elem->invariant()); +#endif if (list->m_next == list) { SASSERT(elem == list); list = nullptr; @@ -123,7 +127,9 @@ public: auto* prev = elem->m_prev; prev->m_next = next; next->m_prev = prev; +#if DLIST_EXTRA_ASSERTIONS SASSERT(list->invariant()); +#endif } static void push_to_front(T*& list, T* elem) {