From 14ca99b22469808642034813156281a203cfee5e Mon Sep 17 00:00:00 2001 From: Max Kellermann Date: Sun, 18 Jan 2009 15:40:50 +0100 Subject: stats: use one db_walk() to obtain stats Don't use dbUtils.h functions. This reduces 4 full database walks to just one. --- src/dbUtils.c | 41 ----------------------------------------- 1 file changed, 41 deletions(-) (limited to 'src/dbUtils.c') diff --git a/src/dbUtils.c b/src/dbUtils.c index 3677b2ae6..cd1476d9d 100644 --- a/src/dbUtils.c +++ b/src/dbUtils.c @@ -50,16 +50,6 @@ typedef struct _SearchStats { unsigned long playTime; } SearchStats; -static int -countSongsInDirectory(struct directory *directory, void *data) -{ - int *count = (int *)data; - - *count += directory->songs.nr; - - return 0; -} - static int printDirectoryInDirectory(struct directory *directory, void *data) { @@ -237,43 +227,12 @@ directoryPrintSongInfo(struct song *song, void *data) return 0; } -static int -sumSongTime(struct song *song, void *data) -{ - unsigned long *sum_time = (unsigned long *)data; - - if (song->tag && song->tag->time >= 0) - *sum_time += song->tag->time; - - return 0; -} - int printInfoForAllIn(struct client *client, const char *name) { return db_walk(name, directoryPrintSongInfo, printDirectoryInDirectory, client); } -int countSongsIn(const char *name) -{ - int count = 0; - void *ptr = (void *)&count; - - db_walk(name, NULL, countSongsInDirectory, ptr); - - return count; -} - -unsigned long sumSongTimesIn(const char *name) -{ - unsigned long dbPlayTime = 0; - void *ptr = (void *)&dbPlayTime; - - db_walk(name, sumSongTime, NULL, ptr); - - return dbPlayTime; -} - static ListCommandItem *newListCommandItem(int tagType, int numConditionals, LocateTagItem * conditionals) { -- cgit v1.2.3