From 22c8e636dcb8c77c71cfd2e6032ce8ac15241375 Mon Sep 17 00:00:00 2001 From: Martchus Date: Thu, 29 Jun 2017 18:24:11 +0200 Subject: [PATCH] Write digitToChar() in a more compact way --- conversion/stringconversion.h | 10 ++-------- 1 file changed, 2 insertions(+), 8 deletions(-) diff --git a/conversion/stringconversion.h b/conversion/stringconversion.h index 19bf659..b59e252 100644 --- a/conversion/stringconversion.h +++ b/conversion/stringconversion.h @@ -232,15 +232,9 @@ template void findAndReplace(StringType &str, const String * - Uses capital letters. * - Valid values for \a digit: 0 <= \a digit <= 35 */ -template CharType digitToChar(CharType digit) +template constexpr CharType digitToChar(CharType digit) { - CharType res; - if (digit <= 9) { - res = digit + '0'; - } else { - res = digit + 'A' - 10; - } - return res; + return digit <= 9 ? (digit + '0') : (digit + 'A' - 10); } /*!