From cfe12f716b0e138b51e3d8f5e481c4d9624459dc Mon Sep 17 00:00:00 2001 From: Thiago Macieira Date: Tue, 18 Nov 2014 13:46:21 -0800 Subject: Merge the different implementations of toHex in one central place It's a simple enough function, but we don't need to duplicate those 17 bytes all over the place. Now they'll be duplicated at most once per library. Change-Id: Ic995e2a934b005e7e996e70f2ee644bfa948eb38 Reviewed-by: Jason McDonald --- src/corelib/plugin/quuid.cpp | 9 +++------ 1 file changed, 3 insertions(+), 6 deletions(-) (limited to 'src/corelib/plugin/quuid.cpp') diff --git a/src/corelib/plugin/quuid.cpp b/src/corelib/plugin/quuid.cpp index 4a5f4e791d3..f7c569f1239 100644 --- a/src/corelib/plugin/quuid.cpp +++ b/src/corelib/plugin/quuid.cpp @@ -36,14 +36,13 @@ #include "qdatastream.h" #include "qendian.h" #include "qdebug.h" +#include "private/qtools_p.h" #ifndef QT_BOOTSTRAPPED #include "qcryptographichash.h" #endif QT_BEGIN_NAMESPACE -static const char digits[] = "0123456789abcdef"; - template void _q_toHex(Char *&dst, Integral value) { @@ -52,10 +51,8 @@ void _q_toHex(Char *&dst, Integral value) const char* p = reinterpret_cast(&value); for (uint i = 0; i < sizeof(Integral); ++i, dst += 2) { - uint j = (p[i] >> 4) & 0xf; - dst[0] = Char(digits[j]); - j = p[i] & 0xf; - dst[1] = Char(digits[j]); + dst[0] = Char(QtMiscUtils::toHexLower((p[i] >> 4) & 0xf)); + dst[1] = Char(QtMiscUtils::toHexLower(p[i] & 0xf)); } } -- cgit v1.2.3