From: Alan T. DeKok Date: Tue, 23 Aug 2022 19:33:20 +0000 (-0400) Subject: simplifications X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=9e9fcb7a8bc933a4388e472e588fe0c73e9bfa0d;p=thirdparty%2Ffreeradius-server.git simplifications --- diff --git a/src/lib/unlang/xlat_expr.c b/src/lib/unlang/xlat_expr.c index 6e10908b7d8..de5b96d7708 100644 --- a/src/lib/unlang/xlat_expr.c +++ b/src/lib/unlang/xlat_expr.c @@ -1757,17 +1757,6 @@ static const fr_sbuff_term_elem_t binary_ops[T_TOKEN_LAST] = { [ T_OP_REG_NE ] = L("reg_ne"), }; -/* - * These operations are N-ary. i.e. we can concatenate all of - * their arguments together. - * - * @todo - add T_ADD - */ -static const bool nary_ops[T_TOKEN_LAST] = { - [T_LAND] = true, - [T_LOR] = true, -}; - /* * Which are logical operations */ @@ -2636,14 +2625,12 @@ redo: fr_assert(func != NULL); /* - * If it's an n-ary operation, AND the LHS is the function we're currently using, then just add "rhs" to the - * "lhs" children. + * If it's a logical operator, then perhaps we can + * statically evaluate the arguments, and simplify the + * condition. If we can't simplify the con */ - if (nary_ops[op] && (lhs->type == XLAT_FUNC) && (lhs->call.func->token == op)) { - /* - * Reparse module return codes if necessary. - */ - if (logical_ops[op] && (reparse_rcode(head, &rhs, true) < 0)) { + if (logical_ops[op] && (lhs->type == XLAT_FUNC) && (lhs->call.func->token == op)) { + if (reparse_rcode(head, &rhs, true) < 0) { fr_sbuff_set(&our_in, &m_rhs); return -fr_sbuff_used(&our_in); }