From 9c1c180ae03917f0209146961b6ef3336b48b519 Mon Sep 17 00:00:00 2001 From: Max Kellermann Date: Wed, 26 Oct 2016 18:26:01 +0200 Subject: [PATCH] tag/Item: declare value[] to have only one element By declaring the variable-length array to have a nominal size of 1, struct TagPoolSlot shrinks from 24 bytes to 16 bytes, because "ref" and "item" now both fit in one machine word. --- src/tag/TagItem.hxx | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/tag/TagItem.hxx b/src/tag/TagItem.hxx index 86c9646ef..ebea73ac1 100644 --- a/src/tag/TagItem.hxx +++ b/src/tag/TagItem.hxx @@ -34,13 +34,14 @@ struct TagItem { /** * the value of this tag; this is a variable length string */ - char value[sizeof(long) - sizeof(type)]; + char value[1]; TagItem() = default; TagItem(const TagItem &other) = delete; TagItem &operator=(const TagItem &other) = delete; }; +static_assert(sizeof(TagItem) == 2, "Unexpected size"); static_assert(alignof(TagItem) == 1, "Unexpected alignment"); #endif