Skip to content

Commit

Permalink
SongPage: use libfmt
Browse files Browse the repository at this point in the history
  • Loading branch information
MaxKellermann committed Sep 2, 2024
1 parent c7877a2 commit f4150e7
Showing 1 changed file with 8 additions and 13 deletions.
21 changes: 8 additions & 13 deletions src/SongPage.cxx
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,8 @@

#include <mpd/client.h>

#include <fmt/format.h>

#include <algorithm>
#include <iterator>
#include <vector>
Expand Down Expand Up @@ -294,9 +296,8 @@ SongPage::AddSong(const struct mpd_song *song) noexcept
{
assert(song != nullptr);

char songpos[16];
snprintf(songpos, sizeof(songpos), "%d", mpd_song_get_pos(song) + 1);
AppendLine(get_tag_label(LABEL_POSITION), songpos,
AppendLine(get_tag_label(LABEL_POSITION),
fmt::format_int{mpd_song_get_pos(song) + 1}.c_str(),
max_tag_label_width);

AppendTag(song, MPD_TAG_ARTIST);
Expand Down Expand Up @@ -360,17 +361,11 @@ SongPage::AddStats(struct mpd_connection *connection) noexcept

lines.emplace_back(_("MPD statistics"));

char buf[64];
snprintf(buf, sizeof(buf), "%d",
mpd_stats_get_number_of_artists(mpd_stats));
AppendStatsLine(STATS_ARTISTS, buf);
snprintf(buf, sizeof(buf), "%d",
mpd_stats_get_number_of_albums(mpd_stats));
AppendStatsLine(STATS_ALBUMS, buf);
snprintf(buf, sizeof(buf), "%d",
mpd_stats_get_number_of_songs(mpd_stats));
AppendStatsLine(STATS_SONGS, buf);
AppendStatsLine(STATS_ARTISTS, fmt::format_int{mpd_stats_get_number_of_artists(mpd_stats)}.c_str());
AppendStatsLine(STATS_ALBUMS, fmt::format_int{mpd_stats_get_number_of_albums(mpd_stats)}.c_str());
AppendStatsLine(STATS_SONGS, fmt::format_int{mpd_stats_get_number_of_songs(mpd_stats)}.c_str());

char buf[64];
format_duration_long(buf, mpd_stats_get_db_play_time(mpd_stats));
AppendStatsLine(STATS_DBPLAYTIME, buf);

Expand Down

0 comments on commit f4150e7

Please sign in to comment.