summaryrefslogtreecommitdiff
path: root/AK
diff options
context:
space:
mode:
authorLenny Maiorani <lenny@colorado.edu>2021-05-17 15:01:04 -0600
committerAndreas Kling <kling@serenityos.org>2021-05-18 08:07:01 +0200
commit44a9c7c23e223c464d5d4a15c93c9fc7ab8525f0 (patch)
tree86ccb1777a1562d3b254ee072603b8561305ce8a /AK
parent3908a49661a00e15621748dcb2b0424f29433571 (diff)
downloadserenity-44a9c7c23e223c464d5d4a15c93c9fc7ab8525f0.zip
AK/PrintfImplementation: Change static constexpr array to function local
Problem: - Static variables take memory and can be subject to less optimization. - This static variable is only used in 1 place. Solution: - Move the variable into the function and make it non-static.
Diffstat (limited to 'AK')
-rw-r--r--AK/PrintfImplementation.h6
1 files changed, 3 insertions, 3 deletions
diff --git a/AK/PrintfImplementation.h b/AK/PrintfImplementation.h
index 0ebeecb000..318e1d06c1 100644
--- a/AK/PrintfImplementation.h
+++ b/AK/PrintfImplementation.h
@@ -19,9 +19,6 @@ extern "C" size_t strlen(const char*);
namespace PrintfImplementation {
-static constexpr const char* printf_hex_digits_lower = "0123456789abcdef";
-static constexpr const char* printf_hex_digits_upper = "0123456789ABCDEF";
-
template<typename PutChFunc, typename T>
ALWAYS_INLINE int print_hex(PutChFunc putch, char*& bufptr, T number, bool upper_case, bool alternate_form, bool left_pad, bool zero_pad, u8 field_width)
{
@@ -64,6 +61,9 @@ ALWAYS_INLINE int print_hex(PutChFunc putch, char*& bufptr, T number, bool upper
} else {
u8 shift_count = digits * 4;
while (shift_count) {
+ constexpr const char* printf_hex_digits_lower = "0123456789abcdef";
+ constexpr const char* printf_hex_digits_upper = "0123456789ABCDEF";
+
shift_count -= 4;
putch(bufptr,
upper_case