make copyTag to metadatachunk a little more efficient

git-svn-id: https://svn.musicpd.org/mpd/trunk@2594 09075e82-0dd4-0310-85a5-a0d7c8717e4f
This commit is contained in:
Warren Dukes 2004-11-11 00:04:16 +00:00
parent ce5a17b4d5
commit 01b494a852

View File

@ -49,7 +49,7 @@ MpdTag * metadataChunkToMpdTagDup(MetadataChunk * chunk) {
} }
#define copyStringToChunk(string, element) { \ #define copyStringToChunk(string, element) { \
if(string && (slen = strlen(string)) && \ if(element < 0 && string && (slen = strlen(string)) && \
pos < METADATA_BUFFER_LENGTH-1) \ pos < METADATA_BUFFER_LENGTH-1) \
{ \ { \
strncpy(chunk->buffer+pos, string, \ strncpy(chunk->buffer+pos, string, \
@ -62,21 +62,26 @@ MpdTag * metadataChunkToMpdTagDup(MetadataChunk * chunk) {
void copyMpdTagToMetadataChunk(MpdTag * tag, MetadataChunk * chunk) { void copyMpdTagToMetadataChunk(MpdTag * tag, MetadataChunk * chunk) {
int pos = 0; int pos = 0;
int slen; int slen;
int i;
initMetadataChunk(chunk); initMetadataChunk(chunk);
if(!tag) return; if(!tag) return;
copyStringToChunk( for(i = 0; i < tag->numOfItems; i++) {
getNextItemFromMpdTag(tag, TAG_ITEM_NAME, NULL), switch(tag->items[i].type) {
chunk->name); case TAG_ITEM_NAME:
copyStringToChunk( copyStringToChunk(tag->items[i].value, chunk->name);
getNextItemFromMpdTag(tag, TAG_ITEM_TITLE, NULL), break;
chunk->title); case TAG_ITEM_TITLE:
copyStringToChunk( copyStringToChunk(tag->items[i].value, chunk->title);
getNextItemFromMpdTag(tag, TAG_ITEM_ARTIST, NULL), break;
chunk->artist); case TAG_ITEM_ARTIST:
copyStringToChunk( copyStringToChunk(tag->items[i].value, chunk->artist);
getNextItemFromMpdTag(tag, TAG_ITEM_ALBUM, NULL), break;
chunk->album); case TAG_ITEM_ALBUM:
copyStringToChunk(tag->items[i].value, chunk->artist);
break;
}
}
} }