aboutsummaryrefslogtreecommitdiffstats
path: root/src/quick/util/qquickglobal.cpp
diff options
context:
space:
mode:
authorAnton Kudryavtsev <a.kudryavtsev@netris.ru>2016-04-06 15:23:58 +0300
committerAnton Kudryavtsev <a.kudryavtsev@netris.ru>2016-04-26 10:31:19 +0000
commit1be53f4e143d417d60cd1f9a292193dab59b5b20 (patch)
treeefc9f54af4d646d9e7d5618e3c2688d9442bbc71 /src/quick/util/qquickglobal.cpp
parent84f61dd2d2b0140814b39a2c5238a6e31c49abd7 (diff)
Use QStringRef to optimize memory allocation
Replace substring functions that return QString with corresponding functions that return QStringRef where it's possible. Create QString from QStringRef only where necessary. While touching the code, also port loops to C++11 style. Change-Id: I04c99b24ea6afd3715e3edf9ea00bfab838fd53c Reviewed-by: Ulf Hermann <ulf.hermann@qt.io> Reviewed-by: Simon Hausmann <simon.hausmann@theqtcompany.com> Reviewed-by: Frank Meerkoetter <frank.meerkoetter@basyskom.com> Reviewed-by: Shawn Rutledge <shawn.rutledge@theqtcompany.com> Reviewed-by: Robin Burchell <robin.burchell@viroteck.net>
Diffstat (limited to 'src/quick/util/qquickglobal.cpp')
-rw-r--r--src/quick/util/qquickglobal.cpp22
1 files changed, 11 insertions, 11 deletions
diff --git a/src/quick/util/qquickglobal.cpp b/src/quick/util/qquickglobal.cpp
index ef54917434..be4c968ab2 100644
--- a/src/quick/util/qquickglobal.cpp
+++ b/src/quick/util/qquickglobal.cpp
@@ -172,8 +172,8 @@ public:
int index = s.indexOf(QLatin1Char(','));
bool xGood, yGood;
- float xCoord = s.left(index).toFloat(&xGood);
- float yCoord = s.mid(index+1).toFloat(&yGood);
+ float xCoord = s.leftRef(index).toFloat(&xGood);
+ float yCoord = s.midRef(index + 1).toFloat(&yGood);
if (xGood && yGood) {
if (ok) *ok = true;
@@ -192,9 +192,9 @@ public:
int index2 = s.indexOf(QLatin1Char(','), index+1);
bool xGood, yGood, zGood;
- float xCoord = s.left(index).toFloat(&xGood);
- float yCoord = s.mid(index+1, index2-index-1).toFloat(&yGood);
- float zCoord = s.mid(index2+1).toFloat(&zGood);
+ float xCoord = s.leftRef(index).toFloat(&xGood);
+ float yCoord = s.midRef(index + 1, index2 - index - 1).toFloat(&yGood);
+ float zCoord = s.midRef(index2 + 1).toFloat(&zGood);
if (xGood && yGood && zGood) {
if (ok) *ok = true;
@@ -214,10 +214,10 @@ public:
int index3 = s.indexOf(QLatin1Char(','), index2+1);
bool xGood, yGood, zGood, wGood;
- float xCoord = s.left(index).toFloat(&xGood);
- float yCoord = s.mid(index+1, index2-index-1).toFloat(&yGood);
- float zCoord = s.mid(index2+1, index3-index2-1).toFloat(&zGood);
- float wCoord = s.mid(index3+1).toFloat(&wGood);
+ float xCoord = s.leftRef(index).toFloat(&xGood);
+ float yCoord = s.midRef(index + 1, index2 - index - 1).toFloat(&yGood);
+ float zCoord = s.midRef(index2 + 1, index3 - index2 - 1).toFloat(&zGood);
+ float wCoord = s.midRef(index3 + 1).toFloat(&wGood);
if (xGood && yGood && zGood && wGood) {
if (ok) *ok = true;
@@ -257,10 +257,10 @@ public:
if (s.count(QLatin1Char(',')) == 15) {
float matValues[16];
bool vOK = true;
- QString mutableStr = s;
+ QStringRef mutableStr(&s);
for (int i = 0; vOK && i < 16; ++i) {
int cidx = mutableStr.indexOf(QLatin1Char(','));
- matValues[i] = mutableStr.leftRef(cidx).toDouble(&vOK);
+ matValues[i] = mutableStr.left(cidx).toDouble(&vOK);
mutableStr = mutableStr.mid(cidx + 1);
}