Skip to content

Commit 65d8816

Browse files
committed
use yp_statements_node_body_length a little bit more
1 parent 820af7a commit 65d8816

File tree

1 file changed

+6
-2
lines changed

1 file changed

+6
-2
lines changed

src/yarp.c

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -725,6 +725,10 @@ yp_statements_node_create(yp_parser_t *parser);
725725
static void
726726
yp_statements_node_body_append(yp_statements_node_t *node, yp_node_t *statement);
727727

728+
// Get the length of the given StatementsNode node's body.
729+
static size_t
730+
yp_statements_node_body_length(yp_statements_node_t *node);
731+
728732
// This function is here to allow us a place to extend in the future when we
729733
// implement our own arena allocation.
730734
static inline void *
@@ -2654,7 +2658,7 @@ yp_if_node_create(yp_parser_t *parser,
26542658
end = end_keyword->end;
26552659
} else if (consequent != NULL) {
26562660
end = consequent->location.end;
2657-
} else if ((statements != NULL) && (statements->body.size != 0)) {
2661+
} else if (yp_statements_node_body_length(statements) != 0) {
26582662
end = statements->base.location.end;
26592663
} else {
26602664
end = predicate->location.end;
@@ -4008,7 +4012,7 @@ yp_rescue_node_reference_set(yp_rescue_node_t *node, yp_node_t *reference) {
40084012
static void
40094013
yp_rescue_node_statements_set(yp_rescue_node_t *node, yp_statements_node_t *statements) {
40104014
node->statements = statements;
4011-
if ((statements != NULL) && (statements->body.size > 0)) {
4015+
if (yp_statements_node_body_length(statements) > 0) {
40124016
node->base.location.end = statements->base.location.end;
40134017
}
40144018
}

0 commit comments

Comments
 (0)