From 0f52cd0bab0d992a4fb5abdd56912d025f34c08f Mon Sep 17 00:00:00 2001 From: Rangi42 Date: Thu, 7 Mar 2024 14:48:23 -0500 Subject: [PATCH] Use `std::reverse` for binary digits --- src/asm/format.cpp | 12 +++--------- 1 file changed, 3 insertions(+), 9 deletions(-) diff --git a/src/asm/format.cpp b/src/asm/format.cpp index 12d0046a..b966a4f5 100644 --- a/src/asm/format.cpp +++ b/src/asm/format.cpp @@ -2,6 +2,7 @@ #include "asm/format.hpp" +#include #include #include #include @@ -190,17 +191,10 @@ void FormatSpec::printNumber(char *buf, size_t bufLen, uint32_t value) { value >>= 1; } while (value); - *ptr = '\0'; - // Reverse the digits - size_t valueLen = ptr - valueBuf; + std::reverse(valueBuf, ptr); - for (size_t i = 0, j = valueLen - 1; i < j; i++, j--) { - char c = valueBuf[i]; - - valueBuf[i] = valueBuf[j]; - valueBuf[j] = c; - } + *ptr = '\0'; } else if (type == 'f') { // Special case for fixed-point