]> git.tuebingen.mpg.de Git - paraslash.git/blobdiff - mood.c
mood: Don't open-code compute_dynamic_score().
[paraslash.git] / mood.c
diff --git a/mood.c b/mood.c
index e60ef2fd6fc97cac81d65e32431749dab3c935eb..db5d8afc6d13c6ecb892545844ae0c45ee469dd2 100644 (file)
--- a/mood.c
+++ b/mood.c
@@ -474,13 +474,9 @@ static long compute_last_played_score(struct afs_info *afsi)
                statistics.last_played_sum, statistics.last_played_qd);
 }
 
-static long compute_dynamic_score(const struct osl_row *aft_row)
+static long compute_dynamic_score(struct afs_info *afsi)
 {
-       struct afs_info afsi;
-
-       if (get_afsi_of_row(aft_row, &afsi) < 0)
-               return -100;
-       return compute_num_played_score(&afsi) + compute_last_played_score(&afsi);
+       return compute_num_played_score(afsi) + compute_last_played_score(afsi);
 }
 
 static int add_afs_statistics(const struct osl_row *row)
@@ -672,7 +668,13 @@ static int update_afs_statistics(struct afs_info *old_afsi, struct afs_info *new
 
 static int add_to_score_table(const struct osl_row *aft_row, long mood_score)
 {
-       long score = (compute_dynamic_score(aft_row) + mood_score) / 3;
+       long score;
+       struct afs_info afsi;
+       int ret = get_afsi_of_row(aft_row, &afsi);
+
+       if (ret < 0)
+               return ret;
+       score = (compute_dynamic_score(&afsi) + mood_score) / 3;
        return score_add(aft_row, score);
 }
 
@@ -753,8 +755,7 @@ static int mood_update_audio_file(const struct osl_row *aft_row,
                if (ret < 0)
                        return ret;
        }
-       score += compute_num_played_score(&afsi);
-       score += compute_last_played_score(&afsi);
+       score += compute_dynamic_score(&afsi);
        score /= 3;
        PARA_DEBUG_LOG("score: %li\n", score);
        percent = (score + 100) / 3;