diff options
author | Anton Kudryavtsev <a.kudryavtsev@netris.ru> | 2016-07-11 16:08:00 +0300 |
---|---|---|
committer | Anton Kudryavtsev <a.kudryavtsev@netris.ru> | 2016-08-16 20:08:31 +0000 |
commit | 8617ce5c881c7913e144153494b15d60ca0c0e83 (patch) | |
tree | 88cfebc8386a1d0f6b0a4d52c2321d3d380dee81 /src/gui/text/qcssparser.cpp | |
parent | ff00b2efbd359b1241dfdc4caf325d8f4b7e6118 (diff) |
Use QStringRef() more, exploiting its new ::chop()
Change-Id: Id2201639be604b9a32b2dc5d21e675a961bee477
Reviewed-by: Edward Welbourne <edward.welbourne@qt.io>
Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
Diffstat (limited to 'src/gui/text/qcssparser.cpp')
-rw-r--r-- | src/gui/text/qcssparser.cpp | 20 |
1 files changed, 12 insertions, 8 deletions
diff --git a/src/gui/text/qcssparser.cpp b/src/gui/text/qcssparser.cpp index 72c5d5ff33..8894e4884b 100644 --- a/src/gui/text/qcssparser.cpp +++ b/src/gui/text/qcssparser.cpp @@ -403,8 +403,8 @@ ValueExtractor::ValueExtractor(const QVector<Declaration> &decls, const QPalette LengthData ValueExtractor::lengthValue(const Value& v) { - QString s = v.variant.toString(); - s.reserve(s.length()); + const QString str = v.variant.toString(); + QStringRef s(&str); LengthData data; data.unit = LengthData::None; if (s.endsWith(QLatin1String("px"), Qt::CaseInsensitive)) @@ -1442,11 +1442,13 @@ bool Declaration::realValue(qreal *real, const char *unit) const const Value &v = d->values.at(0); if (unit && v.type != Value::Length) return false; - QString s = v.variant.toString(); + const QString str = v.variant.toString(); + QStringRef s(&str); if (unit) { - if (!s.endsWith(QLatin1String(unit), Qt::CaseInsensitive)) + const QLatin1String unitStr(unit); + if (!s.endsWith(unitStr, Qt::CaseInsensitive)) return false; - s.chop(qstrlen(unit)); + s.chop(unitStr.size()); } bool ok = false; qreal val = s.toDouble(&ok); @@ -1459,11 +1461,13 @@ static bool intValueHelper(const QCss::Value &v, int *i, const char *unit) { if (unit && v.type != Value::Length) return false; - QString s = v.variant.toString(); + const QString str = v.variant.toString(); + QStringRef s(&str); if (unit) { - if (!s.endsWith(QLatin1String(unit), Qt::CaseInsensitive)) + const QLatin1String unitStr(unit); + if (!s.endsWith(unitStr, Qt::CaseInsensitive)) return false; - s.chop(qstrlen(unit)); + s.chop(unitStr.size()); } bool ok = false; int val = s.toInt(&ok); |