From d9370d0962a4cf3603e53e6903a52e6e37384dfc Mon Sep 17 00:00:00 2001 From: Anton Kudryavtsev Date: Thu, 5 Oct 2023 18:07:58 +0300 Subject: [PATCH] QByteArray: use constexpr more MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Change-Id: I89bfb51659df798bc4dfa37d764b56ea8a289fbf Reviewed-by: Thiago Macieira Reviewed-by: MÃ¥rten Nordheim --- src/corelib/text/qbytearray.cpp | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/src/corelib/text/qbytearray.cpp b/src/corelib/text/qbytearray.cpp index 85bdf6a8bf..b0e3590e28 100644 --- a/src/corelib/text/qbytearray.cpp +++ b/src/corelib/text/qbytearray.cpp @@ -4108,12 +4108,12 @@ auto QtPrivate::toFloat(QByteArrayView a) noexcept -> ParsedNumber */ QByteArray QByteArray::toBase64(Base64Options options) const { - const char alphabet_base64[] = "ABCDEFGH" "IJKLMNOP" "QRSTUVWX" "YZabcdef" - "ghijklmn" "opqrstuv" "wxyz0123" "456789+/"; - const char alphabet_base64url[] = "ABCDEFGH" "IJKLMNOP" "QRSTUVWX" "YZabcdef" - "ghijklmn" "opqrstuv" "wxyz0123" "456789-_"; + constexpr char alphabet_base64[] = "ABCDEFGH" "IJKLMNOP" "QRSTUVWX" "YZabcdef" + "ghijklmn" "opqrstuv" "wxyz0123" "456789+/"; + constexpr char alphabet_base64url[] = "ABCDEFGH" "IJKLMNOP" "QRSTUVWX" "YZabcdef" + "ghijklmn" "opqrstuv" "wxyz0123" "456789-_"; const char *const alphabet = options & Base64UrlEncoding ? alphabet_base64url : alphabet_base64; - const char padchar = '='; + constexpr char padchar = '='; qsizetype padlen = 0; const qsizetype sz = size(); @@ -4225,7 +4225,7 @@ static char *qulltoa2(char *p, qulonglong n, int base) base = 10; } #endif - const char b = 'a' - 10; + constexpr char b = 'a' - 10; do { const int c = n % base; n /= base; @@ -4242,7 +4242,7 @@ static char *qulltoa2(char *p, qulonglong n, int base) */ QByteArray &QByteArray::setNum(qlonglong n, int base) { - const int buffsize = 66; // big enough for MAX_ULLONG in base 2 + constexpr int buffsize = 66; // big enough for MAX_ULLONG in base 2 char buff[buffsize]; char *p; @@ -4267,7 +4267,7 @@ QByteArray &QByteArray::setNum(qlonglong n, int base) QByteArray &QByteArray::setNum(qulonglong n, int base) { - const int buffsize = 66; // big enough for MAX_ULLONG in base 2 + constexpr int buffsize = 66; // big enough for MAX_ULLONG in base 2 char buff[buffsize]; char *p = qulltoa2(buff + buffsize, n, base);