Small fixes
authorLars Knoll <lars.knoll@digia.com>
Tue, 18 Mar 2014 10:10:28 +0000 (11:10 +0100)
committerThe Qt Project <gerrit-noreply@qt-project.org>
Tue, 25 Mar 2014 09:01:29 +0000 (10:01 +0100)
Don't cast from ushort to uchar and back, and remove a
condition that's always true. Allocate some more
memory for matching.

Change-Id: I8167b6e4b4989365ca0ea8e17f4bdb15c0d8e27d
Reviewed-by: Simon Hausmann <simon.hausmann@digia.com>
src/qml/jsruntime/qv4stringobject.cpp

index f26c77e..7c38ae4 100644 (file)
@@ -450,7 +450,7 @@ static void appendReplacementString(QString *result, const QString &input, const
             uint substStart = JSC::Yarr::offsetNoMatch;
             uint substEnd = JSC::Yarr::offsetNoMatch;
             if (ch == '$') {
-                *result += QLatin1Char(ch);
+                *result += QChar(ch);
                 continue;
             } else if (ch == '&') {
                 substStart = matchOffsets[0];
@@ -463,7 +463,8 @@ static void appendReplacementString(QString *result, const QString &input, const
                 substEnd = input.length();
             } else if (ch >= '1' && ch <= '9') {
                 uint capture = ch - '0';
-                if (capture > 0 && capture < static_cast<uint>(captureCount)) {
+                Q_ASSERT(capture > 0);
+                if (capture < static_cast<uint>(captureCount)) {
                     substStart = matchOffsets[capture * 2];
                     substEnd = matchOffsets[capture * 2 + 1];
                 }
@@ -498,8 +499,8 @@ ReturnedValue StringPrototype::method_replace(CallContext *ctx)
     int numCaptures = 0;
     int numStringMatches = 0;
 
-    uint allocatedMatchOffsets = 32;
-    uint _matchOffsets[32];
+    uint allocatedMatchOffsets = 64;
+    uint _matchOffsets[64];
     uint *matchOffsets = _matchOffsets;
     uint nMatchOffsets = 0;