From 17097d96b7452dbcd099af29239be9480aa9df8f Mon Sep 17 00:00:00 2001 From: Max Kellermann Date: Tue, 7 Feb 2017 18:31:30 +0100 Subject: [PATCH] db/{Count,Print}: use tag_print(), eliminate duplicate code --- src/TagPrint.cxx | 2 +- src/db/Count.cxx | 3 ++- src/db/DatabasePrint.cxx | 6 +++--- 3 files changed, 6 insertions(+), 5 deletions(-) diff --git a/src/TagPrint.cxx b/src/TagPrint.cxx index 41a25c894..1406f669b 100644 --- a/src/TagPrint.cxx +++ b/src/TagPrint.cxx @@ -41,7 +41,7 @@ void tag_print_values(Response &r, const Tag &tag) { for (const auto &i : tag) - r.Format("%s: %s\n", tag_item_names[i.type], i.value); + tag_print(r, i.type, i.value); } void diff --git a/src/db/Count.cxx b/src/db/Count.cxx index 9c3945677..e328e7379 100644 --- a/src/db/Count.cxx +++ b/src/db/Count.cxx @@ -25,6 +25,7 @@ #include "client/Response.hxx" #include "LightSong.hxx" #include "tag/Tag.hxx" +#include "TagPrint.hxx" #include #include @@ -57,7 +58,7 @@ Print(Response &r, TagType group, const TagCountMap &m) assert(unsigned(group) < TAG_NUM_OF_ITEM_TYPES); for (const auto &i : m) { - r.Format("%s: %s\n", tag_item_names[group], i.first.c_str()); + tag_print(r, group, i.first.c_str()); PrintSearchStats(r, i.second); } } diff --git a/src/db/DatabasePrint.cxx b/src/db/DatabasePrint.cxx index 87d441d20..a98553237 100644 --- a/src/db/DatabasePrint.cxx +++ b/src/db/DatabasePrint.cxx @@ -23,6 +23,7 @@ #include "SongFilter.hxx" #include "SongPrint.hxx" #include "TimePrint.hxx" +#include "TagPrint.hxx" #include "client/Response.hxx" #include "Partition.hxx" #include "tag/Tag.hxx" @@ -192,12 +193,11 @@ PrintUniqueTag(Response &r, TagType tag_type, { const char *value = tag.GetValue(tag_type); assert(value != nullptr); - r.Format("%s: %s\n", tag_item_names[tag_type], value); + tag_print(r, tag_type, value); for (const auto &item : tag) if (item.type != tag_type) - r.Format("%s: %s\n", - tag_item_names[item.type], item.value); + tag_print(r, item.type, item.value); } void