summaryrefslogtreecommitdiffstats
path: root/src/corelib/tools
diff options
context:
space:
mode:
authorMarc Mutz <marc.mutz@kdab.com>2015-01-23 21:20:56 +0100
committerMarc Mutz <marc.mutz@kdab.com>2015-02-12 09:57:46 +0000
commit26d94c1ca783782dde134cd6042303a7c4804812 (patch)
treec51036b4fe5b91cb215aeb923cc2ad708a60db4f /src/corelib/tools
parentb436fa590e4d67d19f770431bc40d622ea9120d7 (diff)
QtMiscUtils: mark hex functions noexcept and fromHex constexpr
Change-Id: Ia5b63afa88a87ec995d76d48ac6c185168773369 Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
Diffstat (limited to 'src/corelib/tools')
-rw-r--r--src/corelib/tools/qtools_p.h17
1 files changed, 7 insertions, 10 deletions
diff --git a/src/corelib/tools/qtools_p.h b/src/corelib/tools/qtools_p.h
index 214322ef92..320423d703 100644
--- a/src/corelib/tools/qtools_p.h
+++ b/src/corelib/tools/qtools_p.h
@@ -51,27 +51,24 @@
QT_BEGIN_NAMESPACE
namespace QtMiscUtils {
-inline char toHexUpper(uint value)
+inline char toHexUpper(uint value) Q_DECL_NOTHROW
{
static const char hexdigits[] = "0123456789ABCDEF";
return hexdigits[value & 0xF];
}
-inline char toHexLower(uint value)
+inline char toHexLower(uint value) Q_DECL_NOTHROW
{
static const char hexdigits[] = "0123456789abcdef";
return hexdigits[value & 0xF];
}
-inline int fromHex(uint c)
+Q_DECL_CONSTEXPR inline int fromHex(uint c) Q_DECL_NOTHROW
{
- if ((c >= '0') && (c <= '9'))
- return c - '0';
- if ((c >= 'A') && (c <= 'F'))
- return c - 'A' + 10;
- if ((c >= 'a') && (c <= 'f'))
- return c - 'a' + 10;
- return -1;
+ return ((c >= '0') && (c <= '9')) ? c - '0' :
+ ((c >= 'A') && (c <= 'F')) ? c - 'A' + 10 :
+ ((c >= 'a') && (c <= 'f')) ? c - 'a' + 10 :
+ /* otherwise */ -1;
}
}