summaryrefslogtreecommitdiff
path: root/asl/format.cpp
diff options
context:
space:
mode:
authorSteven Le Rouzic <steven.lerouzic@gmail.com>2024-11-14 23:50:30 +0100
committerSteven Le Rouzic <steven.lerouzic@gmail.com>2024-12-20 15:35:58 +0100
commit678ed0ed00ee93b2f6989de7fb2bc10fb3fb2977 (patch)
tree0f79a608adb7d678dfc120deaa301ae62c5547af /asl/format.cpp
parent8aad6443ded53db1b98aec63172b4e9944b3b6e9 (diff)
Cleanup a bunch of lints
Diffstat (limited to 'asl/format.cpp')
-rw-r--r--asl/format.cpp14
1 files changed, 8 insertions, 6 deletions
diff --git a/asl/format.cpp b/asl/format.cpp
index f0b51e1..d25bade 100644
--- a/asl/format.cpp
+++ b/asl/format.cpp
@@ -118,7 +118,7 @@ void asl::AslFormat(formatter& f, uint32_t v)
void asl::AslFormat(formatter& f, uint64_t v)
{
- static constexpr char pairs[] = {
+ static constexpr char s_pairs_storage[] = {
'0', '0', '0', '1', '0', '2', '0', '3', '0', '4',
'0', '5', '0', '6', '0', '7', '0', '8', '0', '9',
'1', '0', '1', '1', '1', '2', '1', '3', '1', '4',
@@ -141,11 +141,13 @@ void asl::AslFormat(formatter& f, uint64_t v)
'9', '5', '9', '6', '9', '7', '9', '8', '9', '9',
};
+ static constexpr span s_pairs = s_pairs_storage;
+
static constexpr int32_t kMaxDigits = 20;
char buffer[kMaxDigits];
int32_t cursor = kMaxDigits;
- auto write_two = [&buffer, &cursor](const char* str)
+ auto write_two = [&buffer, &cursor](span<const char, 2> str)
{
ASL_ASSERT(cursor >= 2);
buffer[--cursor] = str[1];
@@ -162,20 +164,20 @@ void asl::AslFormat(formatter& f, uint64_t v)
{
uint64_t x = v % 100;
v /= 100;
- write_two(pairs + x * 2);
+ write_two(s_pairs.subspan(static_cast<isize_t>(x * 2)).first<2>());
}
if (v >= 10)
{
- write_two(pairs + v * 2);
+ write_two(s_pairs.subspan(static_cast<isize_t>(v * 2)).first<2>());
}
else if (v > 0 || cursor == kMaxDigits)
{
ASL_ASSERT(v < 10);
- write_one('0' + static_cast<char>(v));
+ write_one(static_cast<char>('0' + v));
}
- f.write({buffer + cursor, kMaxDigits - cursor});
+ f.write(string_view(buffer, kMaxDigits).substr(cursor));
}
void asl::AslFormat(formatter& f, int8_t v)