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:
@@ -24,6 +24,7 @@
|
||||
#include "fs/Path.hxx"
|
||||
#include "util/Domain.hxx"
|
||||
#include "util/Macros.hxx"
|
||||
#include "util/StringView.hxx"
|
||||
#include "Log.hxx"
|
||||
|
||||
#include <adplug/adplug.h>
|
||||
@@ -85,7 +86,7 @@ adplug_scan_tag(TagType type, const std::string &value,
|
||||
TagHandler &handler) noexcept
|
||||
{
|
||||
if (!value.empty())
|
||||
handler.OnTag(type, value.c_str());
|
||||
handler.OnTag(type, {value.data(), value.size()});
|
||||
}
|
||||
|
||||
static bool
|
||||
|
Reference in New Issue
Block a user