Rework special cases in daap_reply_songlist_generic()

Use a pointer comparison instead of strcmp(), now that the fields
have been separated out from the field map.
This commit is contained in:
Julien BLACHE 2010-02-08 19:25:14 +01:00
parent 3df34fe9a8
commit 2524eb0f8f

View File

@ -1408,13 +1408,15 @@ daap_reply_songlist_generic(struct evhttp_request *req, struct evbuffer *evbuf,
continue; continue;
/* Will be prepended to the list */ /* Will be prepended to the list */
if (dfm->mfi_offset == dbmfi_offsetof(item_kind)) if (dfm->field == &dmap_mikd)
{ {
/* item kind */
want_mikd = 1; want_mikd = 1;
continue; continue;
} }
else if (dfm->mfi_offset == dbmfi_offsetof(data_kind)) else if (dfm->field == &dmap_asdk)
{ {
/* data kind */
want_asdk = 1; want_asdk = 1;
continue; continue;
} }
@ -1427,7 +1429,7 @@ daap_reply_songlist_generic(struct evhttp_request *req, struct evbuffer *evbuf,
continue; continue;
/* Here's one exception ... codectype (ascd) is actually an integer */ /* Here's one exception ... codectype (ascd) is actually an integer */
if (dfm->mfi_offset == dbmfi_offsetof(codectype)) if (dfm->field == &dmap_ascd)
{ {
dmap_add_literal(song, dfm->field->tag, *strval, 4); dmap_add_literal(song, dfm->field->tag, *strval, 4);
continue; continue;
@ -1436,7 +1438,7 @@ daap_reply_songlist_generic(struct evhttp_request *req, struct evbuffer *evbuf,
/* Special handling for songalbumid (asai) /* Special handling for songalbumid (asai)
* Return an int64_t hash of the album_artist & album * Return an int64_t hash of the album_artist & album
*/ */
if (strcmp(dfm->field->tag, "asai") == 0) if (dfm->field == &dmap_asai)
{ {
songalbumid = daap_songalbumid(dbmfi.album_artist, dbmfi.album); songalbumid = daap_songalbumid(dbmfi.album_artist, dbmfi.album);