diff options
author | Edward Welbourne <edward.welbourne@qt.io> | 2020-08-05 13:38:02 +0200 |
---|---|---|
committer | Edward Welbourne <edward.welbourne@qt.io> | 2020-08-28 21:27:51 +0200 |
commit | 1fb35832df6371ff53a39436fda7ababa7706df1 (patch) | |
tree | b53eb0d4d8ac40d85b2c7b34372cbe9a2c7a5c27 /util | |
parent | e7db401b48a8b0793ec04c98558ebea0c7bfe515 (diff) |
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>
Diffstat (limited to 'util')
-rw-r--r-- | util/unicode/main.cpp | 71 |
1 files changed, 27 insertions, 44 deletions
diff --git a/util/unicode/main.cpp b/util/unicode/main.cpp index 845d837a5e..167f632e37 100644 --- a/util/unicode/main.cpp +++ b/util/unicode/main.cpp @@ -878,6 +878,14 @@ static const QByteArray sizeOfPropertiesStructCheck = "static_assert(sizeof(Properties) == " + QByteArray::number(SizeOfPropertiesStruct) + ");\n\n"; 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 { return (combiningClass == o.combiningClass && category == o.category @@ -910,25 +918,25 @@ struct PropertyFlags { QChar::JoiningType joining : 3; // from DerivedAge.txt QChar::UnicodeVersion age : 5; - int digitValue; + int digitValue = -1; int mirrorDiff : 16; - int lowerCaseDiff; - int upperCaseDiff; - int titleCaseDiff; - int caseFoldDiff; - bool lowerCaseSpecial; - bool upperCaseSpecial; - bool titleCaseSpecial; - bool caseFoldSpecial; - GraphemeBreakClass graphemeBreakClass; - WordBreakClass wordBreakClass; - SentenceBreakClass sentenceBreakClass; - LineBreakClass lineBreakClass; - int script; + int lowerCaseDiff = 0; + int upperCaseDiff = 0; + int titleCaseDiff = 0; + int caseFoldDiff = 0; + bool lowerCaseSpecial = 0; + bool upperCaseSpecial = 0; + bool titleCaseSpecial = 0; + bool caseFoldSpecial = 0; + GraphemeBreakClass graphemeBreakClass = GraphemeBreak_Any; + WordBreakClass wordBreakClass = WordBreak_Any; + SentenceBreakClass sentenceBreakClass = SentenceBreak_Any; + LineBreakClass lineBreakClass = LineBreak_AL; + int script = QChar::Script_Unknown; // from DerivedNormalizationProps.txt - uchar nfQuickCheck; + uchar nfQuickCheck = 0; }; @@ -1006,9 +1014,6 @@ static inline bool isDefaultIgnorable(uint ucs4) struct UnicodeData { UnicodeData(int codepoint = 0) { - p.category = QChar::Other_NotAssigned; // Cn - p.combiningClass = 0; - p.direction = QChar::DirL; // DerivedBidiClass.txt // The unassigned code points that default to AL are in the ranges: @@ -1066,28 +1071,6 @@ struct UnicodeData { else if (codepoint >= 0x20A0 && codepoint <= 0x20CF) { 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); @@ -1095,19 +1078,19 @@ struct UnicodeData { PropertyFlags p; // from UnicodeData.txt - QChar::Decomposition decompositionType; + QChar::Decomposition decompositionType = QChar::NoDecomposition; QList<int> decomposition; QList<int> specialFolding; // from BidiMirroring.txt - int mirroredChar; + int mirroredChar = 0; // DerivedNormalizationProps.txt - bool excludedComposition; + bool excludedComposition = false; // computed position of unicode property set - int propertyIndex; + int propertyIndex = -1; }; static QList<UnicodeData> unicodeData; |