summaryrefslogtreecommitdiffstats
path: root/src/corelib
diff options
context:
space:
mode:
authorMarc Mutz <marc.mutz@kdab.com>2015-01-24 23:01:25 +0100
committerMarc Mutz <marc.mutz@kdab.com>2015-02-12 09:58:10 +0000
commitbcfb535e8252be547b4b11c9c4306aba09eff34e (patch)
tree9b1a8c33ffb9d3200709ccd0f7866f68e04dd210 /src/corelib
parent4b9a0c0a7c739650d0e123032be517eb40c2f32c (diff)
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 <thiago.macieira@intel.com>
Diffstat (limited to 'src/corelib')
-rw-r--r--src/corelib/global/qlogging.cpp12
1 files 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(')');