From 7ee74f870bd26a72504cb5e9d9cd255c163e65c7 Mon Sep 17 00:00:00 2001 From: Marc Mutz Date: Fri, 23 Jan 2015 11:57:36 +0100 Subject: QTextStream: remove a use of QString::sprintf() Instead of using QString::sprintf() (and converting the result back to QByteArray), simply do the conversion from uchar to hex digits ourselves, using QtMiscUtils. This function is a copy of a similar (but not identical) one in qprocess_unix.cpp, but it's not clear whether they can or should be merged (both are only conditionally compiled), so this patch does not attempt to do so. Change-Id: I0be87963f78a98e35a54c98c5fb444756c57b672 Reviewed-by: Oswald Buddenhagen --- src/corelib/io/qtextstream.cpp | 15 +++++++++++---- 1 file changed, 11 insertions(+), 4 deletions(-) (limited to 'src/corelib/io') diff --git a/src/corelib/io/qtextstream.cpp b/src/corelib/io/qtextstream.cpp index e2bb309db9..f870fb11e3 100644 --- a/src/corelib/io/qtextstream.cpp +++ b/src/corelib/io/qtextstream.cpp @@ -233,6 +233,7 @@ static const int QTEXTSTREAM_BUFFERSIZE = 16384; #if defined QTEXTSTREAM_DEBUG #include +#include "private/qtools_p.h" QT_BEGIN_NAMESPACE @@ -250,10 +251,16 @@ static QByteArray qt_prettyDebug(const char *data, int len, int maxSize) case '\n': out += "\\n"; break; case '\r': out += "\\r"; break; case '\t': out += "\\t"; break; - default: - QString tmp; - tmp.sprintf("\\x%x", (unsigned int)(unsigned char)c); - out += tmp.toLatin1(); + default: { + const char buf[] = { + '\\', + 'x', + QtMiscUtils::toHexLower(uchar(c) / 16), + QtMiscUtils::toHexLower(uchar(c) % 16), + 0 + }; + out += buf; + } } } -- cgit v1.2.3