From 0efa0935594ec151c795e562a6614b3e45cbf22c Mon Sep 17 00:00:00 2001 From: Andre Noll Date: Tue, 8 Mar 2022 20:26:34 +0100 Subject: [PATCH] Remove get_num_admissible_files(). This public function had only one caller outside of score.c and this caller already knows the number of admissible files because this number is also stored in the afs statistics structure. Open-coding the remaining caller in score.c allows us to remove the public function. --- afs.h | 1 - mood.c | 6 +----- score.c | 14 +------------- 3 files changed, 2 insertions(+), 19 deletions(-) diff --git a/afs.h b/afs.h index b1606493..a8ba3c45 100644 --- a/afs.h +++ b/afs.h @@ -239,7 +239,6 @@ int score_get_best(struct osl_row **aft_row, long *score); int get_score_and_aft_row(struct osl_row *score_row, long *score, struct osl_row **aft_row); int score_add(const struct osl_row *row, long score); int score_update(const struct osl_row *aft_row, long new_score); -int get_num_admissible_files(unsigned *num); int score_delete(const struct osl_row *aft_row); int clear_score_table(void); int row_belongs_to_score_table(const struct osl_row *aft_row, unsigned *rank); diff --git a/mood.c b/mood.c index 67c18d67..a2c3d099 100644 --- a/mood.c +++ b/mood.c @@ -405,11 +405,7 @@ _static_inline_ int64_t update_quadratic_deviation(int64_t n, int64_t old_qd, static int update_afs_statistics(struct afs_info *old_afsi, struct afs_info *new_afsi) { - unsigned n; - int ret = get_num_admissible_files(&n); - - if (ret < 0) - return ret; + unsigned n = statistics.num; assert(n); statistics.last_played_qd = update_quadratic_deviation(n, diff --git a/score.c b/score.c index 0ecdf601..2f49b104 100644 --- a/score.c +++ b/score.c @@ -76,18 +76,6 @@ static struct osl_table_description score_table_desc = { .column_descriptions = score_cols }; -/** - * Compute the number of files in score table. - * - * \param num Result is returned here. - * - * \return Positive on success, negative on errors. - */ -int get_num_admissible_files(unsigned *num) -{ - return osl(osl_get_num_rows(score_table, num)); -} - /* On errors (negative return value) the content of score is undefined. */ static int get_score_of_row(void *score_row, long *score) { @@ -157,7 +145,7 @@ int score_update(const struct osl_row *aft_row, long percent) return 1; if (ret < 0) return ret; - ret = get_num_admissible_files(&n); + ret = osl(osl_get_num_rows(score_table, &n)); if (ret < 0) return ret; new_pos = 1 + (n - 1) * percent / 100; -- 2.39.2