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:
@@ -30,7 +30,7 @@
|
||||
#include "tag/ReplayGain.hxx"
|
||||
#include "tag/MixRamp.hxx"
|
||||
#include "ReplayGainInfo.hxx"
|
||||
#include "util/DivideString.hxx"
|
||||
#include "util/StringView.hxx"
|
||||
|
||||
#include <assert.h>
|
||||
|
||||
@@ -98,10 +98,10 @@ flac_scan_comment(const FLAC__StreamMetadata_VorbisComment_Entry *entry,
|
||||
TagHandler &handler) noexcept
|
||||
{
|
||||
if (handler.WantPair()) {
|
||||
const char *comment = (const char *)entry->entry;
|
||||
const DivideString split(comment, '=');
|
||||
if (split.IsDefined() && !split.empty())
|
||||
handler.OnPair(split.GetFirst(), split.GetSecond());
|
||||
const StringView comment((const char *)entry->entry);
|
||||
const auto split = StringView(comment).Split('=');
|
||||
if (!split.first.empty() && !split.second.IsNull())
|
||||
handler.OnPair(split.first, split.second);
|
||||
}
|
||||
|
||||
for (const struct tag_table *i = xiph_tags; i->name != nullptr; ++i)
|
||||
|
Reference in New Issue
Block a user