diff options
author | Marc Mutz <marc.mutz@kdab.com> | 2015-06-27 11:13:10 +0200 |
---|---|---|
committer | Marc Mutz <marc.mutz@kdab.com> | 2015-07-16 13:20:44 +0000 |
commit | 73991bee3802e4de8dbe5cc64a881cd93f21a95c (patch) | |
tree | 3ffe0108f458d49b77a96839abbf9a04c629f217 | |
parent | cde7f1b4690094699a550a9021201a399b209d02 (diff) |
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 <david.faure@kdab.com>
-rw-r--r-- | src/corelib/tools/qcommandlineoption.cpp | 10 |
1 files changed, 5 insertions, 5 deletions
diff --git a/src/corelib/tools/qcommandlineoption.cpp b/src/corelib/tools/qcommandlineoption.cpp index 14ee674cb9..e6fccf0443 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()), |