diff options
author | Nathan Froyd <froydnj@gmail.com> | 2023-09-20 13:10:54 -0400 |
---|---|---|
committer | git <svn-admin@ruby-lang.org> | 2023-09-22 14:19:29 +0000 |
commit | 416a8202bc20dab6b6cae1de656f03f90e6da239 (patch) | |
tree | b79e6d48562f28d9d1ddc64f5bf8f1abdab75946 /yarp | |
parent | 02022cef53895cf72181c70a306f5f54f752f069 (diff) | |
download | ruby-416a8202bc20dab6b6cae1de656f03f90e6da239.tar.gz |
[ruby/yarp] use `yp_statements_node_body_length` a little bit more
https://github.com/ruby/yarp/commit/65d8816178
Diffstat (limited to 'yarp')
-rw-r--r-- | yarp/yarp.c | 8 |
1 files changed, 6 insertions, 2 deletions
diff --git a/yarp/yarp.c b/yarp/yarp.c index 9f3656dd61..b6f35da6fa 100644 --- a/yarp/yarp.c +++ b/yarp/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; } } |