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.
This commit is contained in:
@@ -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
|
||||
@@ -31,6 +32,13 @@ tag_print_types(Response &r) noexcept
|
||||
r.Format("tagtype: %s\n", tag_item_names[i]);
|
||||
}
|
||||
|
||||
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
|
||||
{
|
||||
|
Reference in New Issue
Block a user