summaryrefslogtreecommitdiffstats
path: root/src/corelib
diff options
context:
space:
mode:
authorAnton Kudryavtsev <a.kudryavtsev@netris.ru>2016-04-29 14:52:28 +0300
committerAnton Kudryavtsev <a.kudryavtsev@netris.ru>2016-05-13 05:25:55 +0000
commit432d3b696296db9131bfa3daa67285f0eaedec41 (patch)
tree75dd57f40037211b70f41171ea0d4d54bcde5c13 /src/corelib
parent7248e97669373abe2950b6e36a6add45137e3ca4 (diff)
QDateTimeParser: use QStringRef more
Avoid unnecessary allocations. Change-Id: I217ba3fe20293f5cdeeaac2dfae15f837cda51e0 Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
Diffstat (limited to 'src/corelib')
-rw-r--r--src/corelib/tools/qdatetimeparser.cpp17
1 files changed, 8 insertions, 9 deletions
diff --git a/src/corelib/tools/qdatetimeparser.cpp b/src/corelib/tools/qdatetimeparser.cpp
index 8ddf1d9e41..cc8c08d5b1 100644
--- a/src/corelib/tools/qdatetimeparser.cpp
+++ b/src/corelib/tools/qdatetimeparser.cpp
@@ -713,7 +713,7 @@ int QDateTimeParser::parseSection(const QDateTime &currentValue, int sectionInde
QDTPDEBUG << "sectionValue for" << sn.name()
<< "with text" << text << "and st" << sectiontext
- << text.mid(index, sectionmaxsize)
+ << text.midRef(index, sectionmaxsize)
<< index;
int used = 0;
@@ -743,9 +743,8 @@ int QDateTimeParser::parseSection(const QDateTime &currentValue, int sectionInde
QDTPDEBUGN("This should never happen (findAmPm returned %d)", ampm);
break;
}
- if (state != Invalid) {
- text.replace(index, used, sectiontext.left(used));
- }
+ if (state != Invalid)
+ text.replace(index, used, sectiontext.constData(), used);
break; }
case MonthSection:
case DayOfWeekSectionShort:
@@ -764,7 +763,7 @@ int QDateTimeParser::parseSection(const QDateTime &currentValue, int sectionInde
if (num != -1) {
state = (used == sectiontext.size() ? Acceptable : Intermediate);
- text.replace(index, used, sectiontext.left(used));
+ text.replace(index, used, sectiontext.constData(), used);
} else {
state = Intermediate;
}
@@ -810,7 +809,7 @@ int QDateTimeParser::parseSection(const QDateTime &currentValue, int sectionInde
}
}
if (ok && tmp <= absMax) {
- QDTPDEBUG << sectiontext.left(digits) << tmp << digits;
+ QDTPDEBUG << sectiontext.leftRef(digits) << tmp << digits;
last = tmp;
used = digits;
break;
@@ -911,7 +910,7 @@ QDateTimeParser::StateNode QDateTimeParser::parse(QString &input, int &cursorPos
for (int index=0; state != Invalid && index<sectionNodesCount; ++index) {
if (QStringRef(&input, pos, separators.at(index).size()) != separators.at(index)) {
- QDTPDEBUG << "invalid because" << input.mid(pos, separators.at(index).size())
+ QDTPDEBUG << "invalid because" << input.midRef(pos, separators.at(index).size())
<< "!=" << separators.at(index)
<< index << pos << currentSectionIndex;
state = Invalid;
@@ -983,7 +982,7 @@ QDateTimeParser::StateNode QDateTimeParser::parse(QString &input, int &cursorPos
}
if (state != Invalid && QStringRef(&input, pos, input.size() - pos) != separators.last()) {
- QDTPDEBUG << "invalid because" << input.mid(pos)
+ QDTPDEBUG << "invalid because" << input.midRef(pos)
<< "!=" << separators.last() << pos;
state = Invalid;
}
@@ -1384,7 +1383,7 @@ QDateTimeParser::AmPmFinder QDateTimeParser::findAmPm(QString &str, int sectionI
}
if (used)
*used = str.size();
- if (str.trimmed().isEmpty()) {
+ if (QStringRef(&str).trimmed().isEmpty()) {
return PossibleBoth;
}
const QLatin1Char space(' ');