]> git.tue.mpg.de Git - paraslash.git/commitdiff
mood: Simplify compute_dynamic_score().
authorAndre Noll <maan@systemlinux.org>
Wed, 24 Jul 2013 22:43:28 +0000 (00:43 +0200)
committerAndre Noll <maan@systemlinux.org>
Sun, 13 Oct 2013 13:25:06 +0000 (15:25 +0200)
Never use one housekeeping variable when you could just as easily
use two or three. - Roedy Green: How To Write Unmaintainable Code

mood.c

diff --git a/mood.c b/mood.c
index 833820a8b2ff8f13108102f41f1d9578bd564c17..e60ef2fd6fc97cac81d65e32431749dab3c935eb 100644 (file)
--- a/mood.c
+++ b/mood.c
@@ -477,16 +477,10 @@ static long compute_last_played_score(struct afs_info *afsi)
 static long compute_dynamic_score(const struct osl_row *aft_row)
 {
        struct afs_info afsi;
-       int64_t score, nscore = 0, lscore = 0;
-       int ret;
 
-       ret = get_afsi_of_row(aft_row, &afsi);
-       if (ret < 0)
+       if (get_afsi_of_row(aft_row, &afsi) < 0)
                return -100;
-       nscore = compute_num_played_score(&afsi);
-       lscore = compute_last_played_score(&afsi);
-       score = nscore + lscore;
-       return score;
+       return compute_num_played_score(&afsi) + compute_last_played_score(&afsi);
 }
 
 static int add_afs_statistics(const struct osl_row *row)