From: Andre Noll Date: Fri, 18 Mar 2022 17:53:47 +0000 (+0100) Subject: score.c: Merge score_add into score_update(). X-Git-Tag: v0.7.2~14^2~23 X-Git-Url: http://git.tuebingen.mpg.de/?a=commitdiff_plain;h=5564863bb040e340f593b023c873457b8a5d6428;p=paraslash.git score.c: Merge score_add into score_update(). The function is simple and has only one caller. --- diff --git a/score.c b/score.c index 8aa547ef..edc46ed4 100644 --- a/score.c +++ b/score.c @@ -132,16 +132,6 @@ int score_add(const struct osl_row *aft_row, long score) return ret; } -static int get_nth_score(unsigned n, long *score) -{ - struct osl_row *row; - int ret = osl(osl_get_nth_row(score_table, SCORECOL_SCORE, n, &row)); - - if (ret < 0) - return ret; - return get_score_of_row(row, score); -} - /** * Replace a row of the score table. * @@ -156,7 +146,7 @@ static int get_nth_score(unsigned n, long *score) */ int score_update(const struct osl_row *aft_row, long percent) { - struct osl_row *row; + struct osl_row *row, *rrow; /* score row, reference row */ long new_score; unsigned n, new_pos; struct osl_object obj = {.data = (struct osl_row *)aft_row, @@ -171,7 +161,10 @@ int score_update(const struct osl_row *aft_row, long percent) if (ret < 0) return ret; new_pos = 1 + (n - 1) * percent / 100; - ret = get_nth_score(new_pos, &new_score); + ret = osl(osl_get_nth_row(score_table, SCORECOL_SCORE, new_pos, &rrow)); + if (ret < 0) + return ret; + ret = get_score_of_row(rrow, &new_score); if (ret < 0) return ret; new_score--;