]> git.tuebingen.mpg.de Git - paraslash.git/commitdiff
mood.c: Remove row_is_admissible().
authorAndre Noll <maan@tuebingen.mpg.de>
Tue, 8 Mar 2022 22:55:26 +0000 (23:55 +0100)
committerAndre Noll <maan@tuebingen.mpg.de>
Mon, 17 Oct 2022 18:36:21 +0000 (20:36 +0200)
The function has become trivial, so open-code the one-liner twice.
Since mp_eval_row() returns bool and never fails, the comment was
misleading and the error checking unnecessary.

mood.c

diff --git a/mood.c b/mood.c
index acf8e2ad6a324f0a38894a9473bd54c1b097e4db..a58284a75d30f2b0aa008ae69d930b0e90d91edb 100644 (file)
--- a/mood.c
+++ b/mood.c
@@ -119,13 +119,6 @@ __a_const static uint64_t int_sqrt(uint64_t x)
        return res;
 }
 
-/* returns 1 if row admissible, 0 if not, negative on errors */
-static int row_is_admissible(const struct osl_row *aft_row, struct mood *m)
-{
-       assert(m);
-       return mp_eval_row(aft_row, m->parser_context);
-}
-
 static void destroy_mood(struct mood *m)
 {
        if (!m)
@@ -354,11 +347,9 @@ struct admissible_array {
 static int add_if_admissible(struct osl_row *aft_row, void *data)
 {
        struct admissible_array *aa = data;
-       int ret;
 
-       ret = row_is_admissible(aft_row, aa->m);
-       if (ret <= 0)
-               return ret;
+       if (!mp_eval_row(aft_row, aa->m->parser_context))
+               return 0;
        if (statistics.num >= aa->size) {
                aa->size *= 2;
                aa->size += 100;
@@ -499,10 +490,7 @@ static int mood_update_audio_file(const struct osl_row *aft_row,
        if (ret < 0)
                return ret;
        was_admissible = ret;
-       ret = row_is_admissible(aft_row, current_mood);
-       if (ret < 0)
-               return ret;
-       is_admissible = (ret > 0);
+       is_admissible = mp_eval_row(aft_row, current_mood->parser_context);
        if (!was_admissible && !is_admissible)
                return 1;
        if (was_admissible && !is_admissible)