diff options
author | Max Kellermann <max@duempel.org> | 2009-10-31 17:32:00 +0100 |
---|---|---|
committer | Max Kellermann <max@duempel.org> | 2009-10-31 17:32:00 +0100 |
commit | d099a7e46427805711521cad39ce758713c78238 (patch) | |
tree | 78b43c3daaf7420e0f3dffe32f083a53adf073d2 /src/songvec.c | |
parent | 25a806a347ce420126eb75d82c5fb875eb0a5e0d (diff) | |
download | mpd-d099a7e46427805711521cad39ce758713c78238.tar.gz mpd-d099a7e46427805711521cad39ce758713c78238.tar.xz mpd-d099a7e46427805711521cad39ce758713c78238.zip |
songvec: simplified compare_tag_item()
Moved some code to tag_get_value_checked(), to eliminate several NULL
checks.
Diffstat (limited to '')
-rw-r--r-- | src/songvec.c | 18 |
1 files changed, 10 insertions, 8 deletions
diff --git a/src/songvec.c b/src/songvec.c index 4160f14bc..49486bb54 100644 --- a/src/songvec.c +++ b/src/songvec.c @@ -29,6 +29,14 @@ static GMutex *nr_lock = NULL; +static const char * +tag_get_value_checked(const struct tag *tag, enum tag_type type) +{ + return tag != NULL + ? tag_get_value(tag, type) + : NULL; +} + /** * Compare two tag values which should contain an integer value * (e.g. disc or track number). Either one may be NULL. @@ -51,14 +59,8 @@ compare_number_string(const char *a, const char *b) static int compare_tag_item(const struct tag *a, const struct tag *b, enum tag_type type) { - if (a == NULL) - return b == NULL ? 0 : -1; - - if (b == NULL) - return 1; - - return compare_number_string(tag_get_value(a, type), - tag_get_value(b, type)); + return compare_number_string(tag_get_value_checked(a, type), + tag_get_value_checked(b, type)); } /* Only used for sorting/searchin a songvec, not general purpose compares */ |