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>
This commit is contained in:
parent
18088d4706
commit
2737b5e36a
File diff suppressed because it is too large
Load Diff
@ -88,8 +88,8 @@ struct Properties {
|
||||
#endif
|
||||
ushort graphemeBreakClass : 5; /* 5 used */
|
||||
ushort wordBreakClass : 5; /* 5 used */
|
||||
ushort sentenceBreakClass : 8; /* 4 used */
|
||||
ushort lineBreakClass : 6; /* 6 used */
|
||||
ushort sentenceBreakClass : 8; /* 4 used */
|
||||
ushort script : 8;
|
||||
};
|
||||
|
||||
@ -128,6 +128,8 @@ struct CasefoldTraits
|
||||
{ return prop->caseFoldSpecial; }
|
||||
};
|
||||
|
||||
Q_STATIC_ASSERT(sizeof(Properties) == 20);
|
||||
|
||||
enum GraphemeBreakClass {
|
||||
GraphemeBreak_Any,
|
||||
GraphemeBreak_CR,
|
||||
|
@ -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);
|
||||
|
Loading…
x
Reference in New Issue
Block a user