From 65d88161781ca1e186c91732b7ac16c9c97510e7 Mon Sep 17 00:00:00 2001 From: Nathan Froyd Date: Wed, 20 Sep 2023 13:10:54 -0400 Subject: [PATCH] use `yp_statements_node_body_length` a little bit more --- src/yarp.c | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/src/yarp.c b/src/yarp.c index e6e26a93a71..8e29904115c 100644 --- a/src/yarp.c +++ b/src/yarp.c @@ -725,6 +725,10 @@ yp_statements_node_create(yp_parser_t *parser); static void yp_statements_node_body_append(yp_statements_node_t *node, yp_node_t *statement); +// Get the length of the given StatementsNode node's body. +static size_t +yp_statements_node_body_length(yp_statements_node_t *node); + // This function is here to allow us a place to extend in the future when we // implement our own arena allocation. static inline void * @@ -2654,7 +2658,7 @@ yp_if_node_create(yp_parser_t *parser, end = end_keyword->end; } else if (consequent != NULL) { end = consequent->location.end; - } else if ((statements != NULL) && (statements->body.size != 0)) { + } else if (yp_statements_node_body_length(statements) != 0) { end = statements->base.location.end; } else { end = predicate->location.end; @@ -4008,7 +4012,7 @@ yp_rescue_node_reference_set(yp_rescue_node_t *node, yp_node_t *reference) { static void yp_rescue_node_statements_set(yp_rescue_node_t *node, yp_statements_node_t *statements) { node->statements = statements; - if ((statements != NULL) && (statements->body.size > 0)) { + if (yp_statements_node_body_length(statements) > 0) { node->base.location.end = statements->base.location.end; } }