QDateTimeParser: adapt unquote() to make good use of QStringRef.

Avoid unnecessary allocations.

Change-Id: I9bed622c0dd7d9fe993b52d9169d1773957da4f2
Reviewed-by: Edward Welbourne <edward.welbourne@theqtcompany.com>
Reviewed-by: Marc Mutz <marc.mutz@kdab.com>
bb10
Anton Kudryavtsev 2016-04-29 13:24:20 +03:00
parent c6618cb885
commit 361564dacf
1 changed files with 4 additions and 6 deletions

View File

@ -313,7 +313,7 @@ int QDateTimeParser::sectionPos(const SectionNode &sn) const
*/
static QString unquote(const QString &str)
static QString unquote(const QStringRef &str)
{
const QChar quote(QLatin1Char('\''));
const QChar slash(QLatin1Char('\\'));
@ -357,10 +357,8 @@ static inline int countRepeat(const QString &str, int index, int maxCount)
static inline void appendSeparator(QStringList *list, const QString &string, int from, int size, int lastQuote)
{
QString str(string.mid(from, size));
if (lastQuote >= from)
str = unquote(str);
list->append(str);
const QStringRef separator = string.midRef(from, size);
list->append(lastQuote >= from ? unquote(separator) : separator.toString());
}
@ -471,7 +469,7 @@ bool QDateTimeParser::parseFormat(const QString &newFormat)
if (parserType != QVariant::Time) {
const SectionNode sn = { MonthSection, i - add, countRepeat(newFormat, i, 4), 0 };
newSectionNodes.append(sn);
newSeparators.append(unquote(newFormat.mid(index, i - index)));
newSeparators.append(unquote(newFormat.midRef(index, i - index)));
i += sn.count - 1;
index = i + 1;
newDisplay |= MonthSection;