From bcfb535e8252be547b4b11c9c4306aba09eff34e Mon Sep 17 00:00:00 2001 From: Marc Mutz Date: Sat, 24 Jan 2015 23:01:25 +0100 Subject: [PATCH] QLogging: avoid a needless check QString::vasprintf() deals just fine with a nullptr format string, so don't check manually. The main advantage of dropping the check is that in two of three cases, we can replace assignment with initialization, thus saving one default ctor and one (move) assignment. Change-Id: I08dd24111cd0b92f21ef9f1c3e352ede0f66afe0 Reviewed-by: Thiago Macieira --- src/corelib/global/qlogging.cpp | 12 +++--------- 1 file changed, 3 insertions(+), 9 deletions(-) diff --git a/src/corelib/global/qlogging.cpp b/src/corelib/global/qlogging.cpp index af5d7cf55a..1a4221bd72 100644 --- a/src/corelib/global/qlogging.cpp +++ b/src/corelib/global/qlogging.cpp @@ -251,9 +251,7 @@ static inline void convert_to_wchar_t_elided(wchar_t *d, size_t space, const cha static void qt_message(QtMsgType msgType, const QMessageLogContext &context, const char *msg, va_list ap, QString &buf) { - - if (msg) - buf = QString::vasprintf(msg, ap); + buf = QString::vasprintf(msg, ap); qt_message_print(msgType, context, buf); } @@ -1607,11 +1605,9 @@ void qErrnoWarning(const char *msg, ...) { // qt_error_string() will allocate anyway, so we don't have // to be careful here (like we do in plain qWarning()) - QString buf; va_list ap; va_start(ap, msg); - if (msg) - buf = QString::vasprintf(msg, ap); + QString buf = QString::vasprintf(msg, ap); va_end(ap); buf += QLatin1String(" (") + qt_error_string(-1) + QLatin1Char(')'); @@ -1623,11 +1619,9 @@ void qErrnoWarning(int code, const char *msg, ...) { // qt_error_string() will allocate anyway, so we don't have // to be careful here (like we do in plain qWarning()) - QString buf; va_list ap; va_start(ap, msg); - if (msg) - buf = QString::vasprintf(msg, ap); + QString buf = QString::vasprintf(msg, ap); va_end(ap); buf += QLatin1String(" (") + qt_error_string(code) + QLatin1Char(')');