From 2737b5e36a55d9fac78d5339ce4f4f87f8c9a8a6 Mon Sep 17 00:00:00 2001 From: Marc Mutz Date: Tue, 3 Sep 2019 23:40:56 +0200 Subject: QUnicodeTables: pack Properties struct GCC doesn't like the sequence : 5 : 5 : 8 : 6 : 8 and inserts a :6 padding between the :5 and the :8 and a :2 padding between the :6 and the :8, growing the bitfield by 8 bits of embedded padding and another byte to bring the struct back to sizeof % 2 == 0. Fix by reshuffling the elements and adding a static_assert for the next round. Saves ~5KiB in QtCore executable size. Change-Id: I4758a6f48ba389abc2aee92f60997d42ebb0e5b8 Reviewed-by: Thiago Macieira --- util/unicode/main.cpp | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) (limited to 'util/unicode/main.cpp') diff --git a/util/unicode/main.cpp b/util/unicode/main.cpp index 84231c6277..16f9e4be66 100644 --- a/util/unicode/main.cpp +++ b/util/unicode/main.cpp @@ -814,8 +814,8 @@ static const char *property_string = "#endif\n" " ushort graphemeBreakClass : 5; /* 5 used */\n" " ushort wordBreakClass : 5; /* 5 used */\n" - " ushort sentenceBreakClass : 8; /* 4 used */\n" " ushort lineBreakClass : 6; /* 6 used */\n" + " ushort sentenceBreakClass : 8; /* 4 used */\n" " ushort script : 8;\n" "};\n\n" "Q_CORE_EXPORT const Properties * QT_FASTCALL properties(uint ucs4) noexcept;\n" @@ -874,6 +874,9 @@ static const char *methods = static const int SizeOfPropertiesStruct = 20; +static const QByteArray sizeOfPropertiesStructCheck = + "Q_STATIC_ASSERT(sizeof(Properties) == " + QByteArray::number(SizeOfPropertiesStruct) + ");\n\n"; + struct PropertyFlags { bool operator==(const PropertyFlags &o) const { return (combiningClass == o.combiningClass @@ -2502,16 +2505,16 @@ static QByteArray createPropertyInfo() out += ", "; // " ushort graphemeBreakClass : 5; /* 5 used */\n" // " ushort wordBreakClass : 5; /* 5 used */\n" -// " ushort sentenceBreakClass : 8; /* 4 used */\n" // " ushort lineBreakClass : 6; /* 6 used */\n" out += QByteArray::number( p.graphemeBreakClass ); out += ", "; out += QByteArray::number( p.wordBreakClass ); out += ", "; - out += QByteArray::number( p.sentenceBreakClass ); - out += ", "; out += QByteArray::number( p.lineBreakClass ); out += ", "; +// " ushort sentenceBreakClass : 8; /* 4 used */\n" + out += QByteArray::number( p.sentenceBreakClass ); + out += ", "; // " ushort script : 8;\n" out += QByteArray::number( p.script ); out += " },"; @@ -3129,6 +3132,7 @@ int main(int, char **) f.write("#define UNICODE_DATA_VERSION " DATA_VERSION_STR "\n\n"); f.write("namespace QUnicodeTables {\n\n"); f.write(property_string); + f.write(sizeOfPropertiesStructCheck); f.write(grapheme_break_class_string); f.write(word_break_class_string); f.write(sentence_break_class_string); -- cgit v1.2.3