From cde7f1b4690094699a550a9021201a399b209d02 Mon Sep 17 00:00:00 2001 From: Marc Mutz Date: Sat, 27 Jun 2015 11:11:10 +0200 Subject: QCommandLineOption: reduce string data ... by centralizing the common part of repeated qWarnings() in a single function, passing the variable part through %s. Change-Id: I114d10f41d4b0bbf59ef87f75308dc5b3ccd3967 Reviewed-by: David Faure --- src/corelib/tools/qcommandlineoption.cpp | 32 ++++++++++++++++---------------- 1 file changed, 16 insertions(+), 16 deletions(-) (limited to 'src') diff --git a/src/corelib/tools/qcommandlineoption.cpp b/src/corelib/tools/qcommandlineoption.cpp index 8ab98741f5..14ee674cb9 100644 --- a/src/corelib/tools/qcommandlineoption.cpp +++ b/src/corelib/tools/qcommandlineoption.cpp @@ -252,24 +252,24 @@ namespace { result_type operator()(const QString &name) const Q_DECL_NOEXCEPT { - if (name.isEmpty()) { - qWarning("QCommandLineOption: Option names cannot be empty"); - return true; - } else { - const QChar c = name.at(0); - if (c == QLatin1Char('-')) { - qWarning("QCommandLineOption: Option names cannot start with a '-'"); - return true; - } else if (c == QLatin1Char('/')) { - qWarning("QCommandLineOption: Option names cannot start with a '/'"); - return true; - } else if (name.contains(QLatin1Char('='))) { - qWarning("QCommandLineOption: Option names cannot contain a '='"); - return true; - } - } + if (name.isEmpty()) + return warn("be empty"); + + const QChar c = name.at(0); + if (c == QLatin1Char('-')) + return warn("start with a '-'"); + if (c == QLatin1Char('/')) + return warn("start with a '/'"); + if (name.contains(QLatin1Char('='))) + return warn("contain a '='"); + return false; } + static bool warn(const char *what) Q_DECL_NOEXCEPT + { + qWarning("QCommandLineOption: Option names cannot %s", what); + return true; + } }; } // unnamed namespace -- cgit v1.2.3