Don't use QStringLiteral in startsWith/endsWidth
For QLatin1String, startsWith/endsWith is overloaded, so comparing to a latin-1 (C) string literal is efficient, since strlen() is comparatively fast. OTOH, QStringLiteral, when not using RVO, litters the code with QString dtor calls, which are not inline. Worse, absent lambdas, it even allocates memory. So, just use QLatin1String instead. Change-Id: I7eaf464c67b55116f970fe7f58a85f19ce4d254e Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
This commit is contained in:
parent
1a5c0b26d0
commit
1cc06b2e94
@ -88,12 +88,12 @@ QT_BEGIN_NAMESPACE
|
||||
|
||||
static bool isPseudoFs(const QString &mountDir, const QByteArray &type)
|
||||
{
|
||||
if (mountDir.startsWith(QStringLiteral("/dev"))
|
||||
|| mountDir.startsWith(QStringLiteral("/proc"))
|
||||
|| mountDir.startsWith(QStringLiteral("/run"))
|
||||
|| mountDir.startsWith(QStringLiteral("/sys"))
|
||||
|| mountDir.startsWith(QStringLiteral("/var/run"))
|
||||
|| mountDir.startsWith(QStringLiteral("/var/lock"))) {
|
||||
if (mountDir.startsWith(QLatin1String("/dev"))
|
||||
|| mountDir.startsWith(QLatin1String("/proc"))
|
||||
|| mountDir.startsWith(QLatin1String("/run"))
|
||||
|| mountDir.startsWith(QLatin1String("/sys"))
|
||||
|| mountDir.startsWith(QLatin1String("/var/run"))
|
||||
|| mountDir.startsWith(QLatin1String("/var/lock"))) {
|
||||
return true;
|
||||
}
|
||||
#if defined(Q_OS_LINUX)
|
||||
|
@ -61,7 +61,7 @@ void QStorageInfoPrivate::initRootPath()
|
||||
QString path = QDir::toNativeSeparators(rootPath);
|
||||
rootPath.clear();
|
||||
|
||||
if (path.startsWith(QStringLiteral("\\\\?\\")))
|
||||
if (path.startsWith(QLatin1String("\\\\?\\")))
|
||||
path.remove(0, 4);
|
||||
if (path.length() < 2 || path.at(1) != QLatin1Char(':'))
|
||||
return;
|
||||
|
@ -1201,7 +1201,7 @@ void QGuiApplicationPrivate::eventDispatcherReady()
|
||||
static bool runningUnderDebugger()
|
||||
{
|
||||
const QFileInfo parentProcExe(QStringLiteral("/proc/") + QString::number(getppid()) + QStringLiteral("/exe"));
|
||||
return parentProcExe.isSymLink() && parentProcExe.symLinkTarget().endsWith(QStringLiteral("/gdb"));
|
||||
return parentProcExe.isSymLink() && parentProcExe.symLinkTarget().endsWith(QLatin1String("/gdb"));
|
||||
}
|
||||
#endif
|
||||
|
||||
|
@ -396,9 +396,9 @@ static QPageSize::PageSizeId qt_idForPpdKey(const QString &ppdKey, QSize *match
|
||||
return QPageSize::Custom;
|
||||
QString key = ppdKey;
|
||||
// Remove any Rotated or Tranverse modifiers
|
||||
if (key.endsWith(QStringLiteral("Rotated")))
|
||||
if (key.endsWith(QLatin1String("Rotated")))
|
||||
key.chop(7);
|
||||
else if (key.endsWith(QStringLiteral(".Transverse")))
|
||||
else if (key.endsWith(QLatin1String(".Transverse")))
|
||||
key.chop(11);
|
||||
for (int i = 0; i <= int(QPageSize::LastPageSize); ++i) {
|
||||
if (QLatin1String(qt_pageSizes[i].mediaOption) == key) {
|
||||
|
@ -611,7 +611,7 @@ bool QWindowsMimeText::convertFromMime(const FORMATETC &formatetc, const QMimeDa
|
||||
|
||||
bool QWindowsMimeText::canConvertToMime(const QString &mimeType, IDataObject *pDataObj) const
|
||||
{
|
||||
return mimeType.startsWith(QStringLiteral("text/plain"))
|
||||
return mimeType.startsWith(QLatin1String("text/plain"))
|
||||
&& (canGetData(CF_UNICODETEXT, pDataObj)
|
||||
|| canGetData(CF_TEXT, pDataObj));
|
||||
}
|
||||
@ -628,7 +628,7 @@ QString QWindowsMimeText::mimeForFormat(const FORMATETC &formatetc) const
|
||||
QVector<FORMATETC> QWindowsMimeText::formatsForMime(const QString &mimeType, const QMimeData *mimeData) const
|
||||
{
|
||||
QVector<FORMATETC> formatics;
|
||||
if (mimeType.startsWith(QStringLiteral("text/plain")) && mimeData->hasText()) {
|
||||
if (mimeType.startsWith(QLatin1String("text/plain")) && mimeData->hasText()) {
|
||||
formatics += setCf(CF_UNICODETEXT);
|
||||
formatics += setCf(CF_TEXT);
|
||||
}
|
||||
|
@ -2485,7 +2485,7 @@ void QStyleSheetStyle::setProperties(QWidget *w)
|
||||
QSet<const QString> propertySet;
|
||||
for (int i = decls.count() - 1; i >= 0; --i) {
|
||||
const QString property = decls.at(i).d->property;
|
||||
if (!property.startsWith(QStringLiteral("qproperty-"), Qt::CaseInsensitive))
|
||||
if (!property.startsWith(QLatin1String("qproperty-"), Qt::CaseInsensitive))
|
||||
continue;
|
||||
if (!propertySet.contains(property)) {
|
||||
propertySet.insert(property);
|
||||
|
Loading…
x
Reference in New Issue
Block a user