diff options
Diffstat (limited to 'src/gui')
-rw-r--r-- | src/gui/painting/qpagesize.cpp | 2 | ||||
-rw-r--r-- | src/gui/text/qcssparser.cpp | 20 | ||||
-rw-r--r-- | src/gui/text/qzip.cpp | 10 |
3 files changed, 19 insertions, 13 deletions
diff --git a/src/gui/painting/qpagesize.cpp b/src/gui/painting/qpagesize.cpp index f53285d9cb..8831d60d48 100644 --- a/src/gui/painting/qpagesize.cpp +++ b/src/gui/painting/qpagesize.cpp @@ -400,7 +400,7 @@ static QPageSize::PageSizeId qt_idForPpdKey(const QString &ppdKey, QSize *match { if (ppdKey.isEmpty()) return QPageSize::Custom; - QString key = ppdKey; + QStringRef key(&ppdKey); // Remove any Rotated or Tranverse modifiers if (key.endsWith(QLatin1String("Rotated"))) key.chop(7); 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); diff --git a/src/gui/text/qzip.cpp b/src/gui/text/qzip.cpp index 7cb89543ba..b68c36fd9e 100644 --- a/src/gui/text/qzip.cpp +++ b/src/gui/text/qzip.cpp @@ -498,11 +498,13 @@ QZipReader::FileInfo QZipPrivate::fillFileInfo(int index) const // fix the file path, if broken (convert separators, eat leading and trailing ones) fileInfo.filePath = QDir::fromNativeSeparators(fileInfo.filePath); - while (!fileInfo.filePath.isEmpty() && (fileInfo.filePath.at(0) == QLatin1Char('.') || fileInfo.filePath.at(0) == QLatin1Char('/'))) - fileInfo.filePath = fileInfo.filePath.mid(1); - while (!fileInfo.filePath.isEmpty() && fileInfo.filePath.at(fileInfo.filePath.size() - 1) == QLatin1Char('/')) - fileInfo.filePath.chop(1); + QStringRef filePathRef(&fileInfo.filePath); + while (filePathRef.startsWith(QLatin1Char('.')) || filePathRef.startsWith(QLatin1Char('/'))) + filePathRef = filePathRef.mid(1); + while (filePathRef.endsWith(QLatin1Char('/'))) + filePathRef.chop(1); + fileInfo.filePath = filePathRef.toString(); return fileInfo; } |