diff options
author | Chris Robinson <[email protected]> | 2023-08-26 00:52:02 -0700 |
---|---|---|
committer | Chris Robinson <[email protected]> | 2023-08-26 00:52:02 -0700 |
commit | ee62638a0c1033b858de28c7cb1f9365d7cb1c56 (patch) | |
tree | f8967e56ed884dfae7a49af8ceb49129266c58f2 | |
parent | f1a67347a6cf4b6d397fe1220b999ed7161c7097 (diff) |
Simplify building a string message
-rw-r--r-- | al/eax/exception.cpp | 14 |
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; |