aboutsummaryrefslogtreecommitdiffstats
path: root/src/SongSort.cxx
diff options
context:
space:
mode:
authorMax Kellermann <max@duempel.org>2014-01-18 19:08:39 +0100
committerMax Kellermann <max@duempel.org>2014-01-19 02:58:55 +0100
commitd2cf74027c2c252181ab16c1348281c252665353 (patch)
tree50dc8efe859419ad9f266bc277049bae34790c78 /src/SongSort.cxx
parentbc966577ffb2354f44ebb85ceb83b188bb6907b6 (diff)
downloadmpd-d2cf74027c2c252181ab16c1348281c252665353.tar.gz
mpd-d2cf74027c2c252181ab16c1348281c252665353.tar.xz
mpd-d2cf74027c2c252181ab16c1348281c252665353.zip
Song: embed the Tag object statically into class Song
Reduces overhead because we need to manage only one memory allocation. According to valgrind/massif, we save 7%.
Diffstat (limited to 'src/SongSort.cxx')
-rw-r--r--src/SongSort.cxx20
1 files changed, 6 insertions, 14 deletions
diff --git a/src/SongSort.cxx b/src/SongSort.cxx
index 6eac97f10..dcea033b6 100644
--- a/src/SongSort.cxx
+++ b/src/SongSort.cxx
@@ -30,14 +30,6 @@ extern "C" {
#include <stdlib.h>
-static const char *
-tag_get_value_checked(const Tag *tag, TagType type)
-{
- return tag != nullptr
- ? tag->GetValue(type)
- : nullptr;
-}
-
static int
compare_utf8_string(const char *a, const char *b)
{
@@ -55,11 +47,11 @@ compare_utf8_string(const char *a, const char *b)
* nullptr.
*/
static int
-compare_string_tag_item(const Tag *a, const Tag *b,
+compare_string_tag_item(const Tag &a, const Tag &b,
TagType type)
{
- return compare_utf8_string(tag_get_value_checked(a, type),
- tag_get_value_checked(b, type));
+ return compare_utf8_string(a.GetValue(type),
+ b.GetValue(type));
}
/**
@@ -82,10 +74,10 @@ compare_number_string(const char *a, const char *b)
}
static int
-compare_tag_item(const Tag *a, const Tag *b, TagType type)
+compare_tag_item(const Tag &a, const Tag &b, TagType type)
{
- return compare_number_string(tag_get_value_checked(a, type),
- tag_get_value_checked(b, type));
+ return compare_number_string(a.GetValue(type),
+ b.GetValue(type));
}
/* Only used for sorting/searchin a songvec, not general purpose compares */