From: Alan T. DeKok Date: Tue, 25 Jan 2022 14:05:29 +0000 (-0500) Subject: add "has_pure_children" flag X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=ee084df4b65f45354c9146f085ea54e92eff6ac4;p=thirdparty%2Ffreeradius-server.git 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. --- 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