X-Git-Url: http://git.tuebingen.mpg.de/?a=blobdiff_plain;f=mood.c;h=465a48e4efd1df830ac6dff59503e7259f9215f7;hb=2c85cdfd35ad2a647cef47489e51f2a33c1a4b9b;hp=e5e8495369f1e7ffffe36bd463ec5aadf6163e39;hpb=79d6515d49cdb0a91ff7c4a599f2d63cb5678032;p=paraslash.git diff --git a/mood.c b/mood.c index e5e84953..465a48e4 100644 --- a/mood.c +++ b/mood.c @@ -455,19 +455,6 @@ void mood_check_callback(int fd, __a_unused const struct osl_object *query) free(pb.buf); } -#if 0 -static unsigned int_log2(uint64_t x) -{ - unsigned res = 0; - - while (x) { - x /= 2; - res++; - } - return res; -} -#endif - static int64_t normalized_value(int64_t x, int64_t n, int64_t sum, int64_t qd) { if (!n || !qd) @@ -487,19 +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; - int64_t score, nscore = 0, lscore = 0; - int ret; - - ret = get_afsi_of_row(aft_row, &afsi); - if (ret < 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) @@ -691,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); }