aboutsummaryrefslogtreecommitdiffstats
path: root/src/SongUpdate.cxx
diff options
context:
space:
mode:
authorMax Kellermann <max@duempel.org>2013-09-05 19:11:50 +0200
committerMax Kellermann <max@duempel.org>2013-09-26 17:35:08 +0200
commit52ee132d92d4a04d31bbbdeb7c6c0077bd2a2828 (patch)
tree098cf4f9385693b28e41c5342fcdfae416b058dd /src/SongUpdate.cxx
parent7ca0aedcfc35c784d7ae07cd1f1e8dce684e5901 (diff)
downloadmpd-52ee132d92d4a04d31bbbdeb7c6c0077bd2a2828.tar.gz
mpd-52ee132d92d4a04d31bbbdeb7c6c0077bd2a2828.tar.xz
mpd-52ee132d92d4a04d31bbbdeb7c6c0077bd2a2828.zip
TagHandler: use a TagBuilder internally
Reduce heap allocator overhead.
Diffstat (limited to 'src/SongUpdate.cxx')
-rw-r--r--src/SongUpdate.cxx26
1 files changed, 15 insertions, 11 deletions
diff --git a/src/SongUpdate.cxx b/src/SongUpdate.cxx
index 8e9768d55..4c5f35c78 100644
--- a/src/SongUpdate.cxx
+++ b/src/SongUpdate.cxx
@@ -29,6 +29,7 @@
#include "DecoderPlugin.hxx"
#include "DecoderList.hxx"
#include "tag/Tag.hxx"
+#include "tag/TagBuilder.hxx"
#include "tag/TagHandler.hxx"
#include "tag/TagId3.hxx"
#include "tag/ApeTag.hxx"
@@ -113,15 +114,15 @@ Song::UpdateFile()
Mutex mutex;
Cond cond;
+ TagBuilder tag_builder;
+
do {
/* load file tag */
- tag = new Tag();
if (decoder_plugin_scan_file(plugin, path_fs.c_str(),
- &full_tag_handler, tag))
+ &full_tag_handler, &tag_builder))
break;
- delete tag;
- tag = nullptr;
+ tag_builder.Clear();
/* fall back to stream tag */
if (plugin->scan_stream != NULL) {
@@ -134,14 +135,12 @@ Song::UpdateFile()
/* now try the stream_tag() method */
if (is != NULL) {
- tag = new Tag();
if (decoder_plugin_scan_stream(plugin, is,
&full_tag_handler,
- tag))
+ &tag_builder))
break;
- delete tag;
- tag = nullptr;
+ tag_builder.Clear();
is->LockSeek(0, SEEK_SET, IgnoreError());
}
@@ -153,10 +152,15 @@ Song::UpdateFile()
if (is != NULL)
is->Close();
- if (tag != nullptr && tag->IsEmpty())
- tag_scan_fallback(path_fs.c_str(), &full_tag_handler, tag);
+ if (!tag_builder.IsDefined())
+ return false;
+
+ if (tag_builder.IsEmpty())
+ tag_scan_fallback(path_fs.c_str(), &full_tag_handler,
+ &tag_builder);
- return tag != nullptr;
+ tag = tag_builder.Commit();
+ return true;
}
bool