diff options
author | Marc Mutz <marc.mutz@kdab.com> | 2019-09-03 23:40:56 +0200 |
---|---|---|
committer | Marc Mutz <marc.mutz@kdab.com> | 2019-09-04 10:06:19 +0200 |
commit | 2737b5e36a55d9fac78d5339ce4f4f87f8c9a8a6 (patch) | |
tree | 619fe6ff9efab30c5ea94dd7c9bf600ceef32c22 /util/unicode | |
parent | 18088d4706bdd2fefafe7dbb44dc467126f2c795 (diff) |
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 <thiago.macieira@intel.com>
Diffstat (limited to 'util/unicode')
-rw-r--r-- | util/unicode/main.cpp | 12 |
1 files changed, 8 insertions, 4 deletions
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); |