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.
This commit is contained in:
Max Kellermann 2016-10-26 18:26:01 +02:00
parent 06682bd2a9
commit 9c1c180ae0

View File

@ -34,13 +34,14 @@ struct TagItem {
/** /**
* the value of this tag; this is a variable length string * the value of this tag; this is a variable length string
*/ */
char value[sizeof(long) - sizeof(type)]; char value[1];
TagItem() = default; TagItem() = default;
TagItem(const TagItem &other) = delete; TagItem(const TagItem &other) = delete;
TagItem &operator=(const TagItem &other) = delete; TagItem &operator=(const TagItem &other) = delete;
}; };
static_assert(sizeof(TagItem) == 2, "Unexpected size");
static_assert(alignof(TagItem) == 1, "Unexpected alignment"); static_assert(alignof(TagItem) == 1, "Unexpected alignment");
#endif #endif