From 67b4a92b1921cf5f752d10b0e86495cba29a125c Mon Sep 17 00:00:00 2001 From: Max Kellermann Date: Sun, 1 Sep 2024 22:11:39 +0200 Subject: [PATCH] ChatPage: use libfmt to concatenate strings --- src/ChatPage.cxx | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/src/ChatPage.cxx b/src/ChatPage.cxx index 7aac0350..d882dfee 100644 --- a/src/ChatPage.cxx +++ b/src/ChatPage.cxx @@ -15,9 +15,13 @@ #include +#include + #include #include +using std::string_view_literals::operator""sv; + static constexpr char chat_channel[] = "chat"; class ChatPage final : public TextPage { @@ -126,14 +130,14 @@ ChatPage::GetPrefix() noexcept if (user == nullptr) user = "nobody"; - prefix = std::string("<") + user + "> "; + prefix = fmt::format("<{}>"sv, user); return prefix; } void ChatPage::SendMessage(struct mpdclient &c, const char *msg) noexcept { - const std::string full_msg = GetPrefix() + LocaleToUtf8(msg).c_str(); + const std::string full_msg = fmt::format("{}{}"sv, GetPrefix(), LocaleToUtf8(msg).c_str()); (void) mpdclient_cmd_send_message(c, chat_channel, full_msg.c_str()); }