aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorChris Robinson <[email protected]>2023-08-26 00:52:02 -0700
committerChris Robinson <[email protected]>2023-08-26 00:52:02 -0700
commitee62638a0c1033b858de28c7cb1f9365d7cb1c56 (patch)
treef8967e56ed884dfae7a49af8ceb49129266c58f2
parentf1a67347a6cf4b6d397fe1220b999ed7161c7097 (diff)
Simplify building a string message
-rw-r--r--al/eax/exception.cpp14
1 files changed, 3 insertions, 11 deletions
diff --git a/al/eax/exception.cpp b/al/eax/exception.cpp
index cd32e11a..e4945d88 100644
--- a/al/eax/exception.cpp
+++ b/al/eax/exception.cpp
@@ -19,20 +19,12 @@ std::string EaxException::make_message(std::string_view context, std::string_vie
if(context.empty() && message.empty())
return what;
- static constexpr char left_prefix[] = "[";
- static constexpr auto left_prefix_size = std::string::traits_type::length(left_prefix);
-
- static constexpr char right_prefix[] = "] ";
- static constexpr auto right_prefix_size = std::string::traits_type::length(right_prefix);
-
- what.reserve((!context.empty() ? left_prefix_size + context.size() + right_prefix_size : 0) +
- message.length() + 1);
-
+ what.reserve((!context.empty() ? context.size() + 3 : 0) + message.length() + 1);
if(!context.empty())
{
- what.append(left_prefix, left_prefix_size);
+ what += "[";
what += context;
- what.append(right_prefix, right_prefix_size);
+ what += "] ";
}
what += message;