QUnicodeTools: mark a test-only flag constexpr/constinit
For QT_BUILD_INTERNAL, mark the flag constinit, because tests may want to set it (which they better do before Qt spins up threads, because otherwise this non-atomic flag runs into UB (data races)). For non-QT_BUILD_INTERNAL, mark the flag constexpr, so dead code elimination can do its job. Inconsistently, of the two readers of the flag, one was ifdef'ed on QT_BUILD_INTERNAL, while the other wasn't. Settle on exposing both, which increases the compiler coverage of the code. Task-number: QTBUG-100486 Task-number: QTBUG-100485 Change-Id: I6e041359b8214b40d80eefa92c26422aada3eb59 Reviewed-by: Thiago Macieira <thiago.macieira@intel.com> (cherry picked from commit 0c716c687a8c65e7907912d6d5d6beb891238a95) Reviewed-by: Qt Cherry-pick Bot <cherrypick_bot@qt-project.org>
This commit is contained in:
parent
f26c254feb
commit
7ad965b145
@ -20,7 +20,12 @@ QT_BEGIN_NAMESPACE
|
|||||||
|
|
||||||
using namespace Qt::StringLiterals;
|
using namespace Qt::StringLiterals;
|
||||||
|
|
||||||
Q_AUTOTEST_EXPORT int qt_initcharattributes_default_algorithm_only = 0;
|
#ifdef QT_BUILD_INTERNAL
|
||||||
|
Q_CONSTINIT Q_AUTOTEST_EXPORT
|
||||||
|
#else
|
||||||
|
constexpr
|
||||||
|
#endif
|
||||||
|
int qt_initcharattributes_default_algorithm_only = 0;
|
||||||
|
|
||||||
namespace QUnicodeTools {
|
namespace QUnicodeTools {
|
||||||
|
|
||||||
@ -257,7 +262,6 @@ static void getWordBreaks(const char16_t *string, qsizetype len, QCharAttributes
|
|||||||
|
|
||||||
const QUnicodeTables::Properties *prop = QUnicodeTables::properties(ucs4);
|
const QUnicodeTables::Properties *prop = QUnicodeTables::properties(ucs4);
|
||||||
QUnicodeTables::WordBreakClass ncls = (QUnicodeTables::WordBreakClass) prop->wordBreakClass;
|
QUnicodeTables::WordBreakClass ncls = (QUnicodeTables::WordBreakClass) prop->wordBreakClass;
|
||||||
#ifdef QT_BUILD_INTERNAL
|
|
||||||
if (qt_initcharattributes_default_algorithm_only) {
|
if (qt_initcharattributes_default_algorithm_only) {
|
||||||
// as of Unicode 5.1, some punctuation marks were mapped to MidLetter and MidNumLet
|
// as of Unicode 5.1, some punctuation marks were mapped to MidLetter and MidNumLet
|
||||||
// which caused "hi.there" to be treated like if it were just a single word;
|
// which caused "hi.there" to be treated like if it were just a single word;
|
||||||
@ -268,7 +272,6 @@ static void getWordBreaks(const char16_t *string, qsizetype len, QCharAttributes
|
|||||||
else if (ucs4 == 0x003A) // COLON
|
else if (ucs4 == 0x003A) // COLON
|
||||||
ncls = QUnicodeTables::WordBreak_MidLetter;
|
ncls = QUnicodeTables::WordBreak_MidLetter;
|
||||||
}
|
}
|
||||||
#endif
|
|
||||||
|
|
||||||
uchar action = WB::breakTable[cls][ncls];
|
uchar action = WB::breakTable[cls][ncls];
|
||||||
switch (action) {
|
switch (action) {
|
||||||
|
Loading…
x
Reference in New Issue
Block a user