From ee084df4b65f45354c9146f085ea54e92eff6ac4 Mon Sep 17 00:00:00 2001 From: "Alan T. DeKok" Date: Tue, 25 Jan 2022 09:05:29 -0500 Subject: [PATCH] add "has_pure_children" flag so that when we're purifying functions, if the current node is not pure, AND the node has no pure children, then we can short-circuit the walk, and ignore this node. --- src/lib/unlang/xlat.h | 1 + src/lib/unlang/xlat_priv.h | 1 + 2 files changed, 2 insertions(+) diff --git a/src/lib/unlang/xlat.h b/src/lib/unlang/xlat.h index 46d08ce819..2e2655c3a3 100644 --- a/src/lib/unlang/xlat.h +++ b/src/lib/unlang/xlat.h @@ -109,6 +109,7 @@ typedef struct { bool needs_async; //!< Node and all child nodes are guaranteed to not ///< require asynchronous expansion. bool pure; //!< has no external side effects + bool has_pure_children; //!< as the sticker says } xlat_flags_t; /* diff --git a/src/lib/unlang/xlat_priv.h b/src/lib/unlang/xlat_priv.h index b898299e92..3fa717e55b 100644 --- a/src/lib/unlang/xlat_priv.h +++ b/src/lib/unlang/xlat_priv.h @@ -171,6 +171,7 @@ static inline CC_HINT(nonnull) void xlat_flags_merge(xlat_flags_t *parent, xlat_ parent->needs_resolving |= child->needs_resolving; parent->pure &= child->pure; /* purity can only be removed, never added */ parent->pure &= !parent->needs_async; /* things needing async cannot be pure */ + parent->has_pure_children |= child->pure | child->has_pure_children; } /** Set the type of an xlat node -- 2.47.2