summaryrefslogtreecommitdiffstats
path: root/src/corelib/tools/qbytearray.h
diff options
context:
space:
mode:
authorhjk <qthjk@ovi.com>2012-12-20 13:20:43 +0100
committerThe Qt Project <gerrit-noreply@qt-project.org>2012-12-30 10:44:44 +0100
commit03a666760c7abc2d7272e8080c17628b81d0858d (patch)
tree2832d9663aad935ff8497d535610d5380af96253 /src/corelib/tools/qbytearray.h
parent8094c8fe184ae10fe8673bc35a16bfe17b7510ff (diff)
Speed up and fix QByteArray::setNum()
Going through QLocale and QString is not really needed. This also makes the result of the conversion of negative numbers in bases other than 10 independent of the architecture and implements the documented behavior of treating them as unsigned types. Change-Id: Ibc231dc5241deb5cbadd9796484a8b5f79c29410 Reviewed-by: Olivier Goffart <ogoffart@woboq.com>
Diffstat (limited to 'src/corelib/tools/qbytearray.h')
-rw-r--r--src/corelib/tools/qbytearray.h4
1 files changed, 2 insertions, 2 deletions
diff --git a/src/corelib/tools/qbytearray.h b/src/corelib/tools/qbytearray.h
index 50e52a1ca7..860869e9c3 100644
--- a/src/corelib/tools/qbytearray.h
+++ b/src/corelib/tools/qbytearray.h
@@ -581,11 +581,11 @@ inline QByteArray &QByteArray::replace(const char *before, const char *after)
{ return replace(before, qstrlen(before), after, qstrlen(after)); }
inline QByteArray &QByteArray::setNum(short n, int base)
-{ return setNum(qlonglong(n), base); }
+{ return base == 10 ? setNum(qlonglong(n), base) : setNum(qulonglong(ushort(n)), base); }
inline QByteArray &QByteArray::setNum(ushort n, int base)
{ return setNum(qulonglong(n), base); }
inline QByteArray &QByteArray::setNum(int n, int base)
-{ return setNum(qlonglong(n), base); }
+{ return base == 10 ? setNum(qlonglong(n), base) : setNum(qulonglong(uint(n)), base); }
inline QByteArray &QByteArray::setNum(uint n, int base)
{ return setNum(qulonglong(n), base); }
inline QByteArray &QByteArray::setNum(float n, char f, int prec)