TagHandler: use a TagBuilder internally
Reduce heap allocator overhead.
This commit is contained in:
@@ -23,6 +23,7 @@
|
||||
#include "tag/Tag.hxx"
|
||||
#include "tag/TagHandler.hxx"
|
||||
#include "tag/TagTable.hxx"
|
||||
#include "tag/TagBuilder.hxx"
|
||||
#include "replay_gain_info.h"
|
||||
|
||||
#include <glib.h>
|
||||
@@ -231,7 +232,9 @@ void
|
||||
flac_vorbis_comments_to_tag(Tag &tag,
|
||||
const FLAC__StreamMetadata_VorbisComment *comment)
|
||||
{
|
||||
flac_scan_comments(comment, &add_tag_handler, &tag);
|
||||
TagBuilder tag_builder;
|
||||
flac_scan_comments(comment, &add_tag_handler, &tag_builder);
|
||||
tag_builder.Commit(tag);
|
||||
}
|
||||
|
||||
void
|
||||
|
@@ -28,6 +28,7 @@
|
||||
#include "OggCodec.hxx"
|
||||
#include "CheckAudioFormat.hxx"
|
||||
#include "tag/TagHandler.hxx"
|
||||
#include "tag/TagBuilder.hxx"
|
||||
#include "InputStream.hxx"
|
||||
#include "util/Error.hxx"
|
||||
|
||||
@@ -222,14 +223,16 @@ MPDOpusDecoder::HandleBOS(const ogg_packet &packet)
|
||||
inline enum decoder_command
|
||||
MPDOpusDecoder::HandleTags(const ogg_packet &packet)
|
||||
{
|
||||
Tag tag;
|
||||
TagBuilder tag_builder;
|
||||
|
||||
enum decoder_command cmd;
|
||||
if (ScanOpusTags(packet.packet, packet.bytes,
|
||||
&add_tag_handler, &tag) &&
|
||||
!tag.IsEmpty())
|
||||
&add_tag_handler, &tag_builder) &&
|
||||
!tag_builder.IsEmpty()) {
|
||||
Tag tag;
|
||||
tag_builder.Commit(tag);
|
||||
cmd = decoder_tag(decoder, input_stream, std::move(tag));
|
||||
else
|
||||
} else
|
||||
cmd = decoder_get_command(decoder);
|
||||
|
||||
return cmd;
|
||||
|
@@ -23,6 +23,7 @@
|
||||
#include "tag/Tag.hxx"
|
||||
#include "tag/TagTable.hxx"
|
||||
#include "tag/TagHandler.hxx"
|
||||
#include "tag/TagBuilder.hxx"
|
||||
#include "replay_gain_info.h"
|
||||
|
||||
#include <glib.h>
|
||||
@@ -138,13 +139,9 @@ vorbis_comments_scan(char **comments,
|
||||
Tag *
|
||||
vorbis_comments_to_tag(char **comments)
|
||||
{
|
||||
Tag *tag = new Tag();
|
||||
vorbis_comments_scan(comments, &add_tag_handler, tag);
|
||||
|
||||
if (tag->IsEmpty()) {
|
||||
delete tag;
|
||||
tag = NULL;
|
||||
}
|
||||
|
||||
return tag;
|
||||
TagBuilder tag_builder;
|
||||
vorbis_comments_scan(comments, &add_tag_handler, &tag_builder);
|
||||
return tag_builder.IsEmpty()
|
||||
? nullptr
|
||||
: tag_builder.Commit();
|
||||
}
|
||||
|
Reference in New Issue
Block a user