From 73991bee3802e4de8dbe5cc64a881cd93f21a95c Mon Sep 17 00:00:00 2001 From: Marc Mutz Date: Sat, 27 Jun 2015 11:13:10 +0200 Subject: [PATCH] QCommandLineOption: add some Q_UNLIKELY These are all error conditions, and should not happen in practice. Naturally, there's no savings in executable size, because the compiler just shuffles the layout of the branches around. Change-Id: I52b98cc696fd808735c7d73c1f21e02478ff4f5a Reviewed-by: David Faure --- src/corelib/tools/qcommandlineoption.cpp | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/src/corelib/tools/qcommandlineoption.cpp b/src/corelib/tools/qcommandlineoption.cpp index 14ee674cb91..e6fccf04431 100644 --- a/src/corelib/tools/qcommandlineoption.cpp +++ b/src/corelib/tools/qcommandlineoption.cpp @@ -252,15 +252,15 @@ namespace { result_type operator()(const QString &name) const Q_DECL_NOEXCEPT { - if (name.isEmpty()) + if (Q_UNLIKELY(name.isEmpty())) return warn("be empty"); const QChar c = name.at(0); - if (c == QLatin1Char('-')) + if (Q_UNLIKELY(c == QLatin1Char('-'))) return warn("start with a '-'"); - if (c == QLatin1Char('/')) + if (Q_UNLIKELY(c == QLatin1Char('/'))) return warn("start with a '/'"); - if (name.contains(QLatin1Char('='))) + if (Q_UNLIKELY(name.contains(QLatin1Char('=')))) return warn("contain a '='"); return false; @@ -276,7 +276,7 @@ namespace { // static QStringList QCommandLineOptionPrivate::removeInvalidNames(QStringList nameList) { - if (nameList.isEmpty()) + if (Q_UNLIKELY(nameList.isEmpty())) qWarning("QCommandLineOption: Options must have at least one name"); else nameList.erase(std::remove_if(nameList.begin(), nameList.end(), IsInvalidName()),