diff options
author | Steven Le Rouzic <steven.lerouzic@gmail.com> | 2024-11-04 22:34:24 +0100 |
---|---|---|
committer | Steven Le Rouzic <steven.lerouzic@gmail.com> | 2024-12-20 15:35:58 +0100 |
commit | d0a08e9883907847342505c8c5cf459fb84b4aa5 (patch) | |
tree | 6641d67daa98672fdb9713589b7520c2a7085c98 /asl/format.cpp | |
parent | d729d8dc9966fe4af04cf1661649e57888bb41b2 (diff) |
Use span in format
Diffstat (limited to 'asl/format.cpp')
-rw-r--r-- | asl/format.cpp | 17 |
1 files changed, 8 insertions, 9 deletions
diff --git a/asl/format.cpp b/asl/format.cpp index 99ad9da..b410d39 100644 --- a/asl/format.cpp +++ b/asl/format.cpp @@ -5,14 +5,13 @@ void asl::format_internals::format(
writer* writer,
const char* fmt,
- const type_erased_arg* args,
- int64_t arg_count)
+ span<const type_erased_arg> args)
{
formatter f(writer);
-
- int64_t arg = 0;
-
+ const auto* arg_it = args.begin();
+ const auto* arg_end = args.end();
+
const char* begin = fmt;
while (*fmt != '\0')
{
@@ -20,14 +19,14 @@ void asl::format_internals::format( {
if (fmt[1] == '}')
{
- if (arg < arg_count)
+ if (arg_it < arg_end)
{
f.write(begin, fmt - begin);
fmt += 2;
begin = fmt;
- args[arg].fn(f, args[arg].data);
- arg += 1;
+ arg_it->fn(f, arg_it->data);
+ arg_it++; // NOLINT(*-pointer-arithmetic)
}
else
{
@@ -168,7 +167,7 @@ void asl::AslFormat(formatter& f, uint64_t v) else if (v > 0 || cursor == kMaxDigits)
{
ASL_ASSERT(v < 10);
- write_one('0' + (char)v);
+ write_one('0' + static_cast<char>(v));
}
f.write(buffer + cursor, kMaxDigits - cursor);
|