From 43b4eb6c4318de43b163a3b5cae152ad2620d124 Mon Sep 17 00:00:00 2001 From: Tavian Barnes Date: Sun, 21 Feb 2016 15:20:01 -0500 Subject: Make optimizations based on the purity of predicates. This allows something like $ ./bfs -empty -false to avoid evaluating -empty, just like find. --- bfs.h | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) (limited to 'bfs.h') diff --git a/bfs.h b/bfs.h index c9b248d..b365a53 100644 --- a/bfs.h +++ b/bfs.h @@ -111,12 +111,13 @@ enum timeunit { }; struct expr { + /** The function that evaluates this expression. */ + eval_fn *eval; + /** The left hand side of the expression. */ struct expr *lhs; /** The right hand side of the expression. */ struct expr *rhs; - /** The function that evaluates this expression. */ - eval_fn *eval; /** The optional comparison flag. */ enum cmpflag cmp; @@ -138,6 +139,9 @@ struct expr { /** Optional string data for this expression. */ const char *sdata; + + /** Whether this expression has no side effects. */ + bool pure; }; /** -- cgit v1.2.3