From 0bec1d38078c88d07939a4c210b7cdeb9c8eb59c Mon Sep 17 00:00:00 2001 From: Eric Wong Date: Tue, 23 Sep 2008 20:48:39 +0200 Subject: Replace SongList with struct songvec Our linked-list implementation is wasteful and the SongList isn't modified enough to benefit from being a linked list. So use a more compact array of song pointers which saves ~200K on a library with ~9K songs (on x86-32). --- src/song_print.c | 13 +++++++------ 1 file changed, 7 insertions(+), 6 deletions(-) (limited to 'src/song_print.c') diff --git a/src/song_print.c b/src/song_print.c index 77741e768..f754f2348 100644 --- a/src/song_print.c +++ b/src/song_print.c @@ -17,6 +17,7 @@ */ #include "song_print.h" +#include "songvec.h" #include "directory.h" #include "tag_print.h" #include "client.h" @@ -41,14 +42,14 @@ int printSongInfo(struct client *client, Song * song) return 0; } -int printSongInfoFromList(struct client *client, SongList * list) +int songvec_print(struct client *client, const struct songvec *sv) { - ListNode *tempNode = list->firstNode; + int i; + Song **sp = sv->base; - while (tempNode != NULL) { - printSongInfo(client, (Song *) tempNode->data); - tempNode = tempNode->nextNode; - } + for (i = sv->nr; --i >= 0;) + if (printSongInfo(client, *sp++) < 0) + return -1; return 0; } -- cgit v1.2.3