summaryrefslogtreecommitdiff
path: root/AK/CharacterTypes.h
diff options
context:
space:
mode:
authorLenny Maiorani <lenny@serenityos.org>2022-02-09 09:37:36 -0700
committerLinus Groh <mail@linusgroh.de>2022-02-10 10:22:54 +0000
commite5d178528de574e56c913b8d2db6801640e242e7 (patch)
tree56ca66ee889753b9517057fc3a4526875cd49c24 /AK/CharacterTypes.h
parent7be79eeb5e2d45528e3d39a17e76bf96b44974d3 (diff)
downloadserenity-e5d178528de574e56c913b8d2db6801640e242e7.zip
AK: Change static base36 character map to function-local constexpr
Static variables consume memory and can be subject to less optimization. This variable is only used in 1 place and can be moved into the function and make it non-static.
Diffstat (limited to 'AK/CharacterTypes.h')
-rw-r--r--AK/CharacterTypes.h5
1 files changed, 3 insertions, 2 deletions
diff --git a/AK/CharacterTypes.h b/AK/CharacterTypes.h
index d4cdc6d6f1..33d59f4164 100644
--- a/AK/CharacterTypes.h
+++ b/AK/CharacterTypes.h
@@ -1,5 +1,6 @@
/*
* Copyright (c) 2021, Max Wipfli <mail@maxwipfli.ch>
+ * Copyright (c) 2022, the SerenityOS developers.
*
* SPDX-License-Identifier: BSD-2-Clause
*/
@@ -162,10 +163,10 @@ constexpr u32 parse_ascii_base36_digit(u32 code_point)
VERIFY_NOT_REACHED();
}
-static constexpr Array<char, 36> base36_map = { '0', '1', '2', '3', '4', '5', '6', '7', '8', '9', 'a', 'b', 'c', 'd', 'e', 'f', 'g', 'h', 'i', 'j', 'k', 'l', 'm', 'n', 'o', 'p', 'q', 'r', 's', 't', 'u', 'v', 'w', 'x', 'y', 'z' };
constexpr u32 to_ascii_base36_digit(u32 digit)
{
- VERIFY(digit < 36);
+ constexpr Array<char, 36> base36_map = { '0', '1', '2', '3', '4', '5', '6', '7', '8', '9', 'a', 'b', 'c', 'd', 'e', 'f', 'g', 'h', 'i', 'j', 'k', 'l', 'm', 'n', 'o', 'p', 'q', 'r', 's', 't', 'u', 'v', 'w', 'x', 'y', 'z' };
+ VERIFY(digit < base36_map.size());
return base36_map[digit];
}