]> git.ipfire.org Git - thirdparty/freeradius-server.git/commitdiff
add "has_pure_children" flag
authorAlan T. DeKok <aland@freeradius.org>
Tue, 25 Jan 2022 14:05:29 +0000 (09:05 -0500)
committerAlan T. DeKok <aland@freeradius.org>
Tue, 25 Jan 2022 14:06:37 +0000 (09:06 -0500)
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
src/lib/unlang/xlat_priv.h

index 46d08ce819998f3f1fe8c2caded740b315111dfd..2e2655c3a3f6af6da2da79b87cc1898a8c9b94f5 100644 (file)
@@ -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;
 
 /*
index b898299e927b7c9c4fb88a0ccf882eb5763fd8bc..3fa717e55b552fbea4fe07e08fbf255a7b3719e3 100644 (file)
@@ -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