From 134cad32d73c776ffdc9db89a24f582bb847f165 Mon Sep 17 00:00:00 2001 From: Marc Mutz Date: Sat, 17 Oct 2015 17:48:34 +0200 Subject: QtCore: use printf-style qWarning/qDebug where possible (I) The printf-style version of QDebug expands to a lot less code than the std::ostream-style version. Of course, you pay in type safety (but compilers warn about it these days), you cannot stream complex Qt types and streaming QStrings is awkward, but in many cases you actually improve on readability. But the main reason is that something that's not supposed to be executed under normal operation has no business bloating executable code size. This is not an attempt at converting all qWarnings() to printf-style, only the low-hanging fruit. In this first part, replace qWarning() << "" with qWarning("..."). Saves ~750b in text size on optimized GCC 5.3 AMD64 builds. Change-Id: I8bf3e46cd5a6b2cae0ceb3e355a50f61925c63d3 Reviewed-by: Kai Koehne --- src/corelib/json/qjsondocument.cpp | 2 +- src/corelib/json/qjsonparser.cpp | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) (limited to 'src/corelib/json') diff --git a/src/corelib/json/qjsondocument.cpp b/src/corelib/json/qjsondocument.cpp index 1fde69ecf6..b2fa16d22a 100644 --- a/src/corelib/json/qjsondocument.cpp +++ b/src/corelib/json/qjsondocument.cpp @@ -184,7 +184,7 @@ QJsonDocument &QJsonDocument::operator =(const QJsonDocument &other) QJsonDocument QJsonDocument::fromRawData(const char *data, int size, DataValidation validation) { if (quintptr(data) & 3) { - qWarning() <<"QJsonDocument::fromRawData: data has to have 4 byte alignment"; + qWarning("QJsonDocument::fromRawData: data has to have 4 byte alignment"); return QJsonDocument(); } diff --git a/src/corelib/json/qjsonparser.cpp b/src/corelib/json/qjsonparser.cpp index 9bafcc4c5f..04bdb57d6b 100644 --- a/src/corelib/json/qjsonparser.cpp +++ b/src/corelib/json/qjsonparser.cpp @@ -300,7 +300,7 @@ QJsonDocument Parser::parse(QJsonParseError *error) { #ifdef PARSER_DEBUG indent = 0; - qDebug() << ">>>>> parser begin"; + qDebug(">>>>> parser begin"); #endif // allocate some space dataLength = qMax(end - json, (ptrdiff_t) 256); @@ -346,7 +346,7 @@ QJsonDocument Parser::parse(QJsonParseError *error) error: #ifdef PARSER_DEBUG - qDebug() << ">>>>> parser error"; + qDebug(">>>>> parser error"); #endif if (error) { error->offset = json - head; -- cgit v1.2.3