diff options
author | Marc Mutz <marc.mutz@kdab.com> | 2015-01-23 11:57:36 +0100 |
---|---|---|
committer | Marc Mutz <marc.mutz@kdab.com> | 2015-02-02 22:22:56 +0000 |
commit | 7ee74f870bd26a72504cb5e9d9cd255c163e65c7 (patch) | |
tree | 73e94b68cc492229d61ba304df27eaa3032729a8 /src/corelib/io | |
parent | 11abc94b04c6c502231eff1f6e7e2f9853497805 (diff) |
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 <oswald.buddenhagen@theqtcompany.com>
Diffstat (limited to 'src/corelib/io')
-rw-r--r-- | src/corelib/io/qtextstream.cpp | 15 |
1 files changed, 11 insertions, 4 deletions
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 <ctype.h> +#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; + } } } |