diff options
| author | Mau Magnaguagno <maumagnaguagno@gmail.com> | 2023-08-31 14:00:19 -0300 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2023-08-31 10:00:19 -0700 |
| commit | ace41c556a72392a0244d78bca35718f188cf004 (patch) | |
| tree | 12c976eb054f29e7b2b103cb6bf8cc66f2afbb04 | |
| parent | b90457b210e6b1dc465d82dd08db126ce1a8228e (diff) | |
[YARP] Avoid if-else in yp_compile_node (#8336)
Move last node case outside for loop.
Notes
Notes:
Merged-By: jemmaissroff
| -rw-r--r-- | yarp/yarp_compiler.c | 10 |
1 files changed, 3 insertions, 7 deletions
diff --git a/yarp/yarp_compiler.c b/yarp/yarp_compiler.c index bd1352ebd7..f8fc004ce7 100644 --- a/yarp/yarp_compiler.c +++ b/yarp/yarp_compiler.c @@ -1319,14 +1319,10 @@ yp_compile_node(rb_iseq_t *iseq, const yp_node_t *node, LINK_ANCHOR *const ret, case YP_NODE_STATEMENTS_NODE: { yp_statements_node_t *statements_node = (yp_statements_node_t *) node; yp_node_list_t node_list = statements_node->body; - for (size_t index = 0; index < node_list.size; index++) { - if (!popped && (index != node_list.size - 1)) { - yp_compile_node(iseq, node_list.nodes[index], ret, src, true, compile_context); - } - else { - yp_compile_node(iseq, node_list.nodes[index], ret, src, false, compile_context); - } + for (size_t index = 0; index < node_list.size - 1; index++) { + yp_compile_node(iseq, node_list.nodes[index], ret, src, !popped, compile_context); } + yp_compile_node(iseq, node_list.nodes[node_list.size - 1], ret, src, false, compile_context); return; } case YP_NODE_STRING_CONCAT_NODE: { |
