summaryrefslogtreecommitdiffstats
path: root/opt.c
diff options
context:
space:
mode:
authorTavian Barnes <tavianator@tavianator.com>2022-03-27 18:36:14 -0400
committerTavian Barnes <tavianator@tavianator.com>2022-03-27 18:36:14 -0400
commit2d5b15ea68bf4b09afd2374660c22171f8ca3e52 (patch)
tree0b8a70a3111f349eb8a3fa320c45b726a6e34222 /opt.c
parentc04ed01f5c008733c4d4575b888e1c40a8797e24 (diff)
downloadbfs-2d5b15ea68bf4b09afd2374660c22171f8ca3e52.tar.xz
opt: Use floats consistently for probabilities and costs
Diffstat (limited to 'opt.c')
-rw-r--r--opt.c6
1 files changed, 3 insertions, 3 deletions
diff --git a/opt.c b/opt.c
index e21a7ad..f8c0ba3 100644
--- a/opt.c
+++ b/opt.c
@@ -953,7 +953,7 @@ done:
}
/** Swap the children of a binary expression if it would reduce the cost. */
-static bool reorder_expr(const struct opt_state *state, struct bfs_expr *expr, double swapped_cost) {
+static bool reorder_expr(const struct opt_state *state, struct bfs_expr *expr, float swapped_cost) {
if (swapped_cost < expr->cost) {
bool debug = opt_debug(state, 3, "cost: %pe <==> ", expr);
struct bfs_expr *lhs = expr->lhs;
@@ -995,8 +995,8 @@ static bool reorder_expr_recursive(const struct opt_state *state, struct bfs_exp
if (expr->eval_fn == eval_and || expr->eval_fn == eval_or) {
if (lhs->pure && rhs->pure) {
- double rhs_prob = expr->eval_fn == eval_and ? rhs->probability : 1.0 - rhs->probability;
- double swapped_cost = rhs->cost + rhs_prob*lhs->cost;
+ float rhs_prob = expr->eval_fn == eval_and ? rhs->probability : 1.0 - rhs->probability;
+ float swapped_cost = rhs->cost + rhs_prob*lhs->cost;
ret |= reorder_expr(state, expr, swapped_cost);
}
}