diff options
author | Marc Mutz <marc.mutz@kdab.com> | 2015-10-24 22:31:27 +0200 |
---|---|---|
committer | Marc Mutz <marc.mutz@kdab.com> | 2016-05-03 04:35:06 +0000 |
commit | 5a76a3fb03f8d1dc8cb367de1a1dc6a37048376a (patch) | |
tree | 2328d894da121bd0912cb9777f6254cc62296946 /src/corelib/codecs/qicucodec.cpp | |
parent | 0eaac0a3a95f8a74c06d062d3aa7928cbb09d493 (diff) |
QtBase: use printf-style qWarning/qDebug where possible (II)
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 second part, replace
qWarning() << "" << non-QString
with
qWarning("..%.", non-QString).
QString (and QUrl etc) have special escaping handling when streamed
into QDebug, so leave those alone. They also seem to expand to less
code than the qPrintable() alternative, so there's no reason to
replace them.
Saves 2KiB, 3.4KiB, ~750b and ~450b in text size in QtCore, Gui,
Network and Widgets, resp., on optimized GCC 5.3 AMD64 builds.
Change-Id: Iae6823e543544347e628ca1060d6d51e3b04d3f4
Reviewed-by: Kai Koehne <kai.koehne@qt.io>
Diffstat (limited to 'src/corelib/codecs/qicucodec.cpp')
-rw-r--r-- | src/corelib/codecs/qicucodec.cpp | 10 |
1 files changed, 5 insertions, 5 deletions
diff --git a/src/corelib/codecs/qicucodec.cpp b/src/corelib/codecs/qicucodec.cpp index aa2095d9da..ee9f1d0048 100644 --- a/src/corelib/codecs/qicucodec.cpp +++ b/src/corelib/codecs/qicucodec.cpp @@ -527,7 +527,7 @@ QTextCodec *QIcuCodec::codecForNameUnlocked(const char *name) // check whether there is really a converter for the name available. UConverter *conv = ucnv_open(standardName, &error); if (!conv) { - qDebug() << "codecForName: ucnv_open failed" << standardName << u_errorName(error); + qDebug("codecForName: ucnv_open failed %s %s", standardName, u_errorName(error)); return 0; } //qDebug() << "QIcuCodec: Standard name for " << name << "is" << standardName; @@ -577,7 +577,7 @@ UConverter *QIcuCodec::getConverter(QTextCodec::ConverterState *state) const ucnv_setSubstChars(static_cast<UConverter *>(state->d), state->flags & QTextCodec::ConvertInvalidToNull ? "\0" : "?", 1, &error); if (U_FAILURE(error)) - qDebug() << "getConverter(state) ucnv_open failed" << m_name << u_errorName(error); + qDebug("getConverter(state) ucnv_open failed %s %s", m_name, u_errorName(error)); } conv = static_cast<UConverter *>(state->d); } @@ -587,7 +587,7 @@ UConverter *QIcuCodec::getConverter(QTextCodec::ConverterState *state) const conv = ucnv_open(m_name, &error); ucnv_setSubstChars(conv, "?", 1, &error); if (U_FAILURE(error)) - qDebug() << "getConverter(no state) ucnv_open failed" << m_name << u_errorName(error); + qDebug("getConverter(no state) ucnv_open failed %s %s", m_name, u_errorName(error)); } return conv; } @@ -610,7 +610,7 @@ QString QIcuCodec::convertToUnicode(const char *chars, int length, QTextCodec::C &chars, end, 0, false, &error); if (!U_SUCCESS(error) && error != U_BUFFER_OVERFLOW_ERROR) { - qDebug() << "convertToUnicode failed:" << u_errorName(error); + qDebug("convertToUnicode failed: %s", u_errorName(error)); break; } @@ -647,7 +647,7 @@ QByteArray QIcuCodec::convertFromUnicode(const QChar *unicode, int length, QText &uc, end, 0, false, &error); if (!U_SUCCESS(error)) - qDebug() << "convertFromUnicode failed:" << u_errorName(error); + qDebug("convertFromUnicode failed: %s", u_errorName(error)); convertedChars = ch - string.data(); if (uc >= end) break; |