]> git.tuebingen.mpg.de Git - paraslash.git/commitdiff
Remove get_num_admissible_files().
authorAndre Noll <maan@tuebingen.mpg.de>
Tue, 8 Mar 2022 19:26:34 +0000 (20:26 +0100)
committerAndre Noll <maan@tuebingen.mpg.de>
Mon, 17 Oct 2022 18:36:21 +0000 (20:36 +0200)
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
mood.c
score.c

diff --git a/afs.h b/afs.h
index b1606493a05f047afb1e8ecb0fdd0a5bbcbafcfe..a8ba3c451e1d7621c5ec30627f1f959ca27621a6 100644 (file)
--- 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 67c18d6781eb2cd428e1e2b5af9324dd3e50dee0..a2c3d099d1b5f25595e76ae843b1cf18d6a15f4f 100644 (file)
--- 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 0ecdf601456c6e46fe86ec22e8c2dc75474729cb..2f49b104027ecbfc7fcd696deeb71ff6d417ced8 100644 (file)
--- 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;