From d0eea87b1a8d3345b39f6657a6c6efdcab6e7d51 Mon Sep 17 00:00:00 2001 From: Max Kellermann Date: Sat, 25 Nov 2023 20:39:05 +0100 Subject: [PATCH] song/*SongFilter: use libfmt --- src/song/AddedSinceSongFilter.cxx | 6 +++++- src/song/AudioFormatSongFilter.cxx | 10 +++++++--- src/song/ModifiedSinceSongFilter.cxx | 6 +++++- 3 files changed, 17 insertions(+), 5 deletions(-) diff --git a/src/song/AddedSinceSongFilter.cxx b/src/song/AddedSinceSongFilter.cxx index 4b0639f21..efc394fd0 100644 --- a/src/song/AddedSinceSongFilter.cxx +++ b/src/song/AddedSinceSongFilter.cxx @@ -6,10 +6,14 @@ #include "time/ISO8601.hxx" #include "util/StringBuffer.hxx" +#include + +using std::string_view_literals::operator""sv; + std::string AddedSinceSongFilter::ToExpression() const noexcept { - return std::string("(added-since \"") + FormatISO8601(value).c_str() + "\")"; + return fmt::format("(added-since \"{}\")"sv, FormatISO8601(value).c_str()); } bool diff --git a/src/song/AudioFormatSongFilter.cxx b/src/song/AudioFormatSongFilter.cxx index 0aeb37d5e..69bd2b1a8 100644 --- a/src/song/AudioFormatSongFilter.cxx +++ b/src/song/AudioFormatSongFilter.cxx @@ -5,12 +5,16 @@ #include "LightSong.hxx" #include "util/StringBuffer.hxx" +#include + +using std::string_view_literals::operator""sv; + std::string AudioFormatSongFilter::ToExpression() const noexcept { - return std::string("(AudioFormat ") + - (value.IsFullyDefined() ? "==" : "=~") + - " \"" + ToString(value).c_str() + "\")"; + return fmt::format("(AudioFormat {} \"{}\")"sv, + value.IsFullyDefined() ? "==" : "=~", + ToString(value).c_str()); } bool diff --git a/src/song/ModifiedSinceSongFilter.cxx b/src/song/ModifiedSinceSongFilter.cxx index 1c65a4ee6..43879c789 100644 --- a/src/song/ModifiedSinceSongFilter.cxx +++ b/src/song/ModifiedSinceSongFilter.cxx @@ -6,10 +6,14 @@ #include "time/ISO8601.hxx" #include "util/StringBuffer.hxx" +#include + +using std::string_view_literals::operator""sv; + std::string ModifiedSinceSongFilter::ToExpression() const noexcept { - return std::string("(modified-since \"") + FormatISO8601(value).c_str() + "\")"; + return fmt::format("(modified-since \"{}\")"sv, FormatISO8601(value).c_str()); } bool