Simplify initialization of UnicodeData and PropertyFlags structs

Initialize values where they're declared, where possible.

Change-Id: Ib6bf33b27b19c76f406f78bc8a1bd9729bd8f2cd
Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
This commit is contained in:
Edward Welbourne 2020-08-05 13:38:02 +02:00
parent e7db401b48
commit 1fb35832df

View File

@ -878,6 +878,14 @@ static const QByteArray sizeOfPropertiesStructCheck =
"static_assert(sizeof(Properties) == " + QByteArray::number(SizeOfPropertiesStruct) + ");\n\n"; "static_assert(sizeof(Properties) == " + QByteArray::number(SizeOfPropertiesStruct) + ");\n\n";
struct PropertyFlags { struct PropertyFlags {
PropertyFlags()
: combiningClass(0)
, category(QChar::Other_NotAssigned) // Cn
, direction(QChar::DirL)
, joining(QChar::Joining_None)
, age(QChar::Unicode_Unassigned)
, mirrorDiff(0) {}
bool operator==(const PropertyFlags &o) const { bool operator==(const PropertyFlags &o) const {
return (combiningClass == o.combiningClass return (combiningClass == o.combiningClass
&& category == o.category && category == o.category
@ -910,25 +918,25 @@ struct PropertyFlags {
QChar::JoiningType joining : 3; QChar::JoiningType joining : 3;
// from DerivedAge.txt // from DerivedAge.txt
QChar::UnicodeVersion age : 5; QChar::UnicodeVersion age : 5;
int digitValue; int digitValue = -1;
int mirrorDiff : 16; int mirrorDiff : 16;
int lowerCaseDiff; int lowerCaseDiff = 0;
int upperCaseDiff; int upperCaseDiff = 0;
int titleCaseDiff; int titleCaseDiff = 0;
int caseFoldDiff; int caseFoldDiff = 0;
bool lowerCaseSpecial; bool lowerCaseSpecial = 0;
bool upperCaseSpecial; bool upperCaseSpecial = 0;
bool titleCaseSpecial; bool titleCaseSpecial = 0;
bool caseFoldSpecial; bool caseFoldSpecial = 0;
GraphemeBreakClass graphemeBreakClass; GraphemeBreakClass graphemeBreakClass = GraphemeBreak_Any;
WordBreakClass wordBreakClass; WordBreakClass wordBreakClass = WordBreak_Any;
SentenceBreakClass sentenceBreakClass; SentenceBreakClass sentenceBreakClass = SentenceBreak_Any;
LineBreakClass lineBreakClass; LineBreakClass lineBreakClass = LineBreak_AL;
int script; int script = QChar::Script_Unknown;
// from DerivedNormalizationProps.txt // from DerivedNormalizationProps.txt
uchar nfQuickCheck; uchar nfQuickCheck = 0;
}; };
@ -1006,9 +1014,6 @@ static inline bool isDefaultIgnorable(uint ucs4)
struct UnicodeData { struct UnicodeData {
UnicodeData(int codepoint = 0) { UnicodeData(int codepoint = 0) {
p.category = QChar::Other_NotAssigned; // Cn
p.combiningClass = 0;
p.direction = QChar::DirL; p.direction = QChar::DirL;
// DerivedBidiClass.txt // DerivedBidiClass.txt
// The unassigned code points that default to AL are in the ranges: // The unassigned code points that default to AL are in the ranges:
@ -1066,28 +1071,6 @@ struct UnicodeData {
else if (codepoint >= 0x20A0 && codepoint <= 0x20CF) { else if (codepoint >= 0x20A0 && codepoint <= 0x20CF) {
p.lineBreakClass = LineBreak_PR; p.lineBreakClass = LineBreak_PR;
} }
mirroredChar = 0;
decompositionType = QChar::NoDecomposition;
p.joining = QChar::Joining_None;
p.age = QChar::Unicode_Unassigned;
p.mirrorDiff = 0;
p.digitValue = -1;
p.lowerCaseDiff = 0;
p.upperCaseDiff = 0;
p.titleCaseDiff = 0;
p.caseFoldDiff = 0;
p.lowerCaseSpecial = 0;
p.upperCaseSpecial = 0;
p.titleCaseSpecial = 0;
p.caseFoldSpecial = 0;
p.graphemeBreakClass = GraphemeBreak_Any;
p.wordBreakClass = WordBreak_Any;
p.sentenceBreakClass = SentenceBreak_Any;
p.script = QChar::Script_Unknown;
p.nfQuickCheck = 0;
propertyIndex = -1;
excludedComposition = false;
} }
static UnicodeData &valueRef(int codepoint); static UnicodeData &valueRef(int codepoint);
@ -1095,19 +1078,19 @@ struct UnicodeData {
PropertyFlags p; PropertyFlags p;
// from UnicodeData.txt // from UnicodeData.txt
QChar::Decomposition decompositionType; QChar::Decomposition decompositionType = QChar::NoDecomposition;
QList<int> decomposition; QList<int> decomposition;
QList<int> specialFolding; QList<int> specialFolding;
// from BidiMirroring.txt // from BidiMirroring.txt
int mirroredChar; int mirroredChar = 0;
// DerivedNormalizationProps.txt // DerivedNormalizationProps.txt
bool excludedComposition; bool excludedComposition = false;
// computed position of unicode property set // computed position of unicode property set
int propertyIndex; int propertyIndex = -1;
}; };
static QList<UnicodeData> unicodeData; static QList<UnicodeData> unicodeData;