format utility improvements

This commit is contained in:
2025-08-28 14:40:01 -04:00
parent 7808896226
commit c97920c473
3 changed files with 24 additions and 111 deletions

View File

@@ -175,12 +175,11 @@ void benchmark_error_messages() {
constexpr int line_number = 123;
const std::string error_msg = "File not found";
// Arena-based static_format (using std::string_view)
// Arena-based static_format (using string literals only)
bench.run("static_format", [&] {
ArenaAllocator arena(128);
std::string_view error_msg_sv = error_msg;
auto result = static_format(arena, "Error ", error_code, ": ", error_msg_sv,
" (line ", line_number, ")");
auto result = static_format(arena, "Error ", error_code, ": ",
"File not found", " (line ", line_number, ")");
ankerl::nanobench::doNotOptimizeAway(result);
});