From 6d713abb12df82c1c1a5bbbeac5a5d67472d1ca1 Mon Sep 17 00:00:00 2001 From: Andre Noll Date: Tue, 8 Mar 2022 20:47:59 +0100 Subject: [PATCH] Rename admissible_file_loop() -> score_loop(). The function simply iterates the entries of the score table. The new name is shorter, more to the point, and indicates that the function is implemented in score.c. Streamline the documentation while at it and swap the arguments, as the reversed order is more natural. --- afs.h | 2 +- aft.c | 2 +- score.c | 14 ++++++-------- 3 files changed, 8 insertions(+), 10 deletions(-) diff --git a/afs.h b/afs.h index a8ba3c45..43eb8f75 100644 --- a/afs.h +++ b/afs.h @@ -234,7 +234,7 @@ int for_each_matching_row(struct pattern_match_data *pmd); /* score */ void score_init(struct afs_table *t); -int admissible_file_loop(void *data, osl_rbtree_loop_func *func); +int score_loop(osl_rbtree_loop_func *func, void *data); 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); diff --git a/aft.c b/aft.c index f690e819..1f1e1198 100644 --- a/aft.c +++ b/aft.c @@ -1375,7 +1375,7 @@ static int com_ls_callback(struct afs_callback_arg *aca) aca->pbout.flags = (opts->mode == LS_MODE_PARSER)? PBF_SIZE_PREFIX : 0; if (admissible_only(opts)) - ret = admissible_file_loop(opts, prepare_ls_row); + ret = score_loop(prepare_ls_row, opts); else ret = osl(osl_rbtree_loop(audio_file_table, AFTCOL_PATH, opts, prepare_ls_row)); diff --git a/score.c b/score.c index 2f49b104..19cfef86 100644 --- a/score.c +++ b/score.c @@ -196,17 +196,15 @@ static int get_score_row_from_aft_row(const struct osl_row *aft_row, } /** - * Loop over all files in the score table. + * Call the given function for each row of the score table. * - * \param data A pointer to arbitrary data. - * \param func Function to be called for each admissible file. + * \param func Callback, called once per row. + * \param data Passed verbatim to the callback. * - * \return The return value of the underlying call to osl_rbtree_loop(). - * - * This is used for the ls command. The \a data parameter is passed as the - * second argument to \a func. + * \return The return value of the underlying call to osl_rbtree_loop(). The + * loop terminates early if the callback returns negative. */ -int admissible_file_loop(void *data, osl_rbtree_loop_func *func) +int score_loop(osl_rbtree_loop_func *func, void *data) { return osl(osl_rbtree_loop(score_table, SCORECOL_SCORE, data, func)); } -- 2.39.2