From 8e41d9661870a9adf4022f502e4d2bbf525b214d Mon Sep 17 00:00:00 2001 From: Brian Gianforcaro Date: Wed, 18 Aug 2021 17:07:05 -0700 Subject: [PATCH] AK: Enable IntrusiveList self reference to be optimized out when empty If a member is an empty class, the standard normally stats that it needs to have a size of at least 1 byte in order to guarantee that the addresses of distinct objects of the same type are always distinct. However as of c++20, we can use [[no_unique_address]] to instruct the compiler that if the member has an empty type, it may optimize it to occupy no space. --- AK/IntrusiveList.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/AK/IntrusiveList.h b/AK/IntrusiveList.h index 804b3d075f..9aed1f5852 100644 --- a/AK/IntrusiveList.h +++ b/AK/IntrusiveList.h @@ -187,7 +187,7 @@ private: IntrusiveListStorage* m_storage = nullptr; IntrusiveListNode* m_next = nullptr; IntrusiveListNode* m_prev = nullptr; - SelfReferenceIfNeeded m_self; + [[no_unique_address]] SelfReferenceIfNeeded m_self; }; }