From 432d3b696296db9131bfa3daa67285f0eaedec41 Mon Sep 17 00:00:00 2001 From: Anton Kudryavtsev Date: Fri, 29 Apr 2016 14:52:28 +0300 Subject: QDateTimeParser: use QStringRef more Avoid unnecessary allocations. Change-Id: I217ba3fe20293f5cdeeaac2dfae15f837cda51e0 Reviewed-by: Thiago Macieira --- src/corelib/tools/qdatetimeparser.cpp | 17 ++++++++--------- 1 file changed, 8 insertions(+), 9 deletions(-) (limited to 'src/corelib') 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 ¤tValue, 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 ¤tValue, 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 ¤tValue, 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 ¤tValue, 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