summaryrefslogtreecommitdiffstats
path: root/opt.c
diff options
context:
space:
mode:
authorTavian Barnes <tavianator@tavianator.com>2017-12-15 12:40:37 -0500
committerTavian Barnes <tavianator@tavianator.com>2017-12-15 12:40:37 -0500
commit7da0d28318c97f1f3d629f13daad9ec824254709 (patch)
tree565abff45b696b36a006f3ef1472f0db1425a11b /opt.c
parent7d419a51636161e0257c0ccf041b49b97fe5f219 (diff)
downloadbfs-7da0d28318c97f1f3d629f13daad9ec824254709.tar.xz
Keep track of required FDs per-expr
Diffstat (limited to 'opt.c')
-rw-r--r--opt.c13
1 files changed, 13 insertions, 0 deletions
diff --git a/opt.c b/opt.c
index 405f995..a7ebbe2 100644
--- a/opt.c
+++ b/opt.c
@@ -571,6 +571,19 @@ static struct expr *optimize_expr_recursive(struct opt_state *state, struct expr
goto done;
}
+ struct expr *lhs = expr->lhs;
+ struct expr *rhs = expr->rhs;
+ if (rhs) {
+ expr->persistent_fds = rhs->persistent_fds;
+ expr->ephemeral_fds = rhs->ephemeral_fds;
+ }
+ if (lhs) {
+ expr->persistent_fds += lhs->persistent_fds;
+ if (lhs->ephemeral_fds > expr->ephemeral_fds) {
+ expr->ephemeral_fds = lhs->ephemeral_fds;
+ }
+ }
+
if (expr->always_true) {
set_facts_impossible(&state->facts_when_false);
}