summaryrefslogtreecommitdiff
path: root/src/TagPrint.cxx
diff options
context:
space:
mode:
authorMax Kellermann <max@musicpd.org>2019-06-06 12:02:55 +0200
committerMax Kellermann <max@musicpd.org>2019-06-06 13:00:53 +0200
commit548aa00111e781c6b31e9a2486306d607081b1ec (patch)
treef44be7fd991040473082f1b2431c06c8e4c7aeb4 /src/TagPrint.cxx
parent76eb550011312cf5c096c86e7920decfe139b63d (diff)
tag/Handler: pass StringView to OnTag() and OnPair()
Eliminates a number of allocations, because callers don't need to copy the strings to a newly allocated buffer only to null-terminate them. And most callers don't need to have a null-terminated string.
Diffstat (limited to 'src/TagPrint.cxx')
-rw-r--r--src/TagPrint.cxx8
1 files changed, 8 insertions, 0 deletions
diff --git a/src/TagPrint.cxx b/src/TagPrint.cxx
index 412098a97..16b78b654 100644
--- a/src/TagPrint.cxx
+++ b/src/TagPrint.cxx
@@ -21,6 +21,7 @@
#include "tag/Tag.hxx"
#include "tag/Settings.hxx"
#include "client/Response.hxx"
+#include "util/StringView.hxx"
void
tag_print_types(Response &r) noexcept
@@ -32,6 +33,13 @@ tag_print_types(Response &r) noexcept
}
void
+tag_print(Response &r, TagType type, StringView value) noexcept
+{
+ r.Format("%s: %.*s\n", tag_item_names[type],
+ int(value.size), value.data);
+}
+
+void
tag_print(Response &r, TagType type, const char *value) noexcept
{
r.Format("%s: %s\n", tag_item_names[type], value);