optimize QString::toLower()/toUpper() for special cases, step 2
authorKonstantin Ritt <ritt.ks@gmail.com>
Tue, 18 Oct 2011 17:12:21 +0000 (19:12 +0200)
committerQt by Nokia <qt-info@nokia.com>
Tue, 21 Feb 2012 21:31:00 +0000 (22:31 +0100)
from now, QUnicodeTables::specialCaseMap[] starts with a placeholder; so,
if somethingCaseSpecial is true, then somethingCaseDiff is always greater than 0

Change-Id: Ibb1870512836eee71b1521564c0745096c05b2f9
Merge-request: 70
Reviewed-by: Oswald Buddenhagen <oswald.buddenhagen@nokia.com>
Reviewed-by: Olivier
Reviewed-by: Olivier Goffart <ogoffart@woboq.com>
src/corelib/tools/qstring.cpp
util/unicode/main.cpp

index b0c2592..7045456 100644 (file)
@@ -4906,7 +4906,7 @@ QString QString::toLower() const
         } else {
             prop = qGetProp(*p);
         }
-        if (prop->lowerCaseDiff || prop->lowerCaseSpecial) {
+        if (prop->lowerCaseDiff) {
             if (QChar::isLowSurrogate(*p))
                 --p; // safe; diff is 0 for surrogates
             QString s(d->size, Qt::Uninitialized);
@@ -4967,7 +4967,7 @@ QString QString::toCaseFolded() const
         } else {
             prop = qGetProp(*p);
         }
-        if (prop->caseFoldDiff || prop->caseFoldSpecial) {
+        if (prop->caseFoldDiff) {
             if (QChar::isLowSurrogate(*p))
                 --p; // safe; diff is 0 for surrogates
             QString s(d->size, Qt::Uninitialized);
@@ -5028,7 +5028,7 @@ QString QString::toUpper() const
         } else {
             prop = qGetProp(*p);
         }
-        if (prop->upperCaseDiff || prop->upperCaseSpecial) {
+        if (prop->upperCaseDiff) {
             if (QChar::isLowSurrogate(*p))
                 --p; // safe; diff is 0 for surrogates
             QString s(d->size, Qt::Uninitialized);
index 40294eb..4a11ec6 100644 (file)
@@ -476,7 +476,10 @@ static int appendToSpecialCaseMap(const QList<int> &map)
     utf16map.prepend(length);
     specialCaseMaxLen = qMax(specialCaseMaxLen, length);
 
-    int i = 0;
+    if (specialCaseMap.isEmpty())
+        specialCaseMap << 0; // placeholder
+
+    int i = 1;
     while (i < specialCaseMap.size()) {
         int n = specialCaseMap.at(i);
         if (n == length) {
@@ -2251,8 +2254,9 @@ static QByteArray createPropertyInfo()
            "}\n\n";
 
 
-    out += "static const ushort specialCaseMap[] = {";
-    int i = 0;
+    out += "static const ushort specialCaseMap[] = {\n";
+    out += "    0x0, // placeholder";
+    int i = 1;
     while (i < specialCaseMap.size()) {
         out += "\n   ";
         int n = specialCaseMap.at(i);