diff options
author | Warren Dukes <warren.dukes@gmail.com> | 2004-11-11 00:04:16 +0000 |
---|---|---|
committer | Warren Dukes <warren.dukes@gmail.com> | 2004-11-11 00:04:16 +0000 |
commit | 01b494a85245c589ae6369ef75608743b2f73149 (patch) | |
tree | 2ccc6bf0bdd2a8fb374e9f7db63a25a1d60a9023 /src | |
parent | ce5a17b4d577c44564987e0929690cf1e3e95388 (diff) | |
download | mpd-01b494a85245c589ae6369ef75608743b2f73149.tar.gz mpd-01b494a85245c589ae6369ef75608743b2f73149.tar.xz mpd-01b494a85245c589ae6369ef75608743b2f73149.zip |
make copyTag to metadatachunk a little more efficient
git-svn-id: https://svn.musicpd.org/mpd/trunk@2594 09075e82-0dd4-0310-85a5-a0d7c8717e4f
Diffstat (limited to '')
-rw-r--r-- | src/metadataChunk.c | 31 |
1 files changed, 18 insertions, 13 deletions
diff --git a/src/metadataChunk.c b/src/metadataChunk.c index e5c64f7b3..20b0d7c6f 100644 --- a/src/metadataChunk.c +++ b/src/metadataChunk.c @@ -49,7 +49,7 @@ MpdTag * metadataChunkToMpdTagDup(MetadataChunk * chunk) { } #define copyStringToChunk(string, element) { \ - if(string && (slen = strlen(string)) && \ + if(element < 0 && string && (slen = strlen(string)) && \ pos < METADATA_BUFFER_LENGTH-1) \ { \ strncpy(chunk->buffer+pos, string, \ @@ -62,21 +62,26 @@ MpdTag * metadataChunkToMpdTagDup(MetadataChunk * chunk) { void copyMpdTagToMetadataChunk(MpdTag * tag, MetadataChunk * chunk) { int pos = 0; int slen; + int i; initMetadataChunk(chunk); if(!tag) return; - copyStringToChunk( - getNextItemFromMpdTag(tag, TAG_ITEM_NAME, NULL), - chunk->name); - copyStringToChunk( - getNextItemFromMpdTag(tag, TAG_ITEM_TITLE, NULL), - chunk->title); - copyStringToChunk( - getNextItemFromMpdTag(tag, TAG_ITEM_ARTIST, NULL), - chunk->artist); - copyStringToChunk( - getNextItemFromMpdTag(tag, TAG_ITEM_ALBUM, NULL), - chunk->album); + for(i = 0; i < tag->numOfItems; i++) { + switch(tag->items[i].type) { + case TAG_ITEM_NAME: + copyStringToChunk(tag->items[i].value, chunk->name); + break; + case TAG_ITEM_TITLE: + copyStringToChunk(tag->items[i].value, chunk->title); + break; + case TAG_ITEM_ARTIST: + copyStringToChunk(tag->items[i].value, chunk->artist); + break; + case TAG_ITEM_ALBUM: + copyStringToChunk(tag->items[i].value, chunk->artist); + break; + } + } } |