X-Git-Url: http://git.tuebingen.mpg.de/?a=blobdiff_plain;f=mood.c;h=a2c3d099d1b5f25595e76ae843b1cf18d6a15f4f;hb=6d713abb12df82c1c1a5bbbeac5a5d67472d1ca1;hp=acf8e2ad6a324f0a38894a9473bd54c1b097e4db;hpb=6558ba12e9699979aba97292c7cd41889619b83c;p=paraslash.git diff --git a/mood.c b/mood.c index acf8e2ad..a2c3d099 100644 --- 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; @@ -414,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, @@ -489,7 +476,8 @@ static int mood_update_audio_file(const struct osl_row *aft_row, struct afs_info *old_afsi) { long score, percent; - int ret, is_admissible, was_admissible = 0; + int ret; + bool is_admissible, was_admissible; struct afs_info afsi; unsigned rank; @@ -499,10 +487,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) @@ -684,19 +669,16 @@ out: * This function is called on events which render the current list of * admissible files useless, for example if an attribute is removed from the * attribute table. - * - * If no mood is currently open, the function returns success. */ static int reload_current_mood(void) { int ret; char *mood_name = NULL; + assert(current_mood); ret = clear_score_table(); if (ret < 0) return ret; - if (!current_mood) - return 1; PARA_NOTICE_LOG("reloading %s\n", current_mood->name? current_mood->name : "(dummy)"); if (current_mood->name)