QStringRef has toInt(), so no need to create a new QString
authorThiago Macieira <thiago.macieira@intel.com>
Fri, 4 Oct 2013 04:54:18 +0000 (21:54 -0700)
committerThe Qt Project <gerrit-noreply@qt-project.org>
Mon, 7 Oct 2013 06:53:23 +0000 (08:53 +0200)
Saves up on memory allocations.

Change-Id: I0f7c82521b0b10085861fc62fed9b9d591169b5a
Reviewed-by: Simon Hausmann <simon.hausmann@digia.com>
Reviewed-by: Lars Knoll <lars.knoll@digia.com>
src/qml/compiler/qqmlcodegenerator.cpp
src/qml/qml/qqmlscript.cpp

index 2394b07..fb2ca7c 100644 (file)
@@ -742,13 +742,11 @@ void QQmlCodeGenerator::extractVersion(QStringRef string, int *maj, int *min)
         int dot = string.indexOf(QLatin1Char('.'));
 
         if (dot < 0) {
-            *maj = string.toString().toInt();
+            *maj = string.toInt();
             *min = 0;
         } else {
-            const QString *s = string.string();
-            int p = string.position();
-            *maj = QStringRef(s, p, dot).toString().toInt();
-            *min = QStringRef(s, p + dot + 1, string.size() - dot - 1).toString().toInt();
+            *maj = string.left(dot).toInt();
+            *min = string.mid(dot + 1).toInt();
         }
     }
 }
index 58aad8e..7996f9f 100644 (file)
@@ -635,13 +635,11 @@ void ProcessAST::extractVersion(QStringRef string, int *maj, int *min)
         int dot = string.indexOf(QLatin1Char('.'));
 
         if (dot < 0) {
-            *maj = string.toString().toInt();
+            *maj = string.toInt();
             *min = 0;
         } else {
-            const QString *s = string.string();
-            int p = string.position();
-            *maj = QStringRef(s, p, dot).toString().toInt();
-            *min = QStringRef(s, p + dot + 1, string.size() - dot - 1).toString().toInt();
+            *maj = string.left(dot).toInt();
+            *min = string.mid(dot + 1).toInt();
         }
     }
 }