summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorPeter Zhu <peter@peterzhu.ca>2024-01-16 11:09:00 -0500
committerKevin Newton <kddnewton@gmail.com>2024-01-16 12:43:14 -0500
commit70a8ed0775e7a9215bcc6cdf4f6d85da321af304 (patch)
tree5436c8b6ffbee654157fa7826123d36197416365
parent1caa881a56fc0543b2fb4819b6d894008b0ae5a9 (diff)
[PRISM] Don't allocate labels when not needed
The labels lstart, lend, lcont are only needed when there is a rescue clause. They are not needed when there is only an ensure clause or neither.
-rw-r--r--prism_compile.c9
1 files changed, 3 insertions, 6 deletions
diff --git a/prism_compile.c b/prism_compile.c
index e53a0d1cbb..9560232c1f 100644
--- a/prism_compile.c
+++ b/prism_compile.c
@@ -3201,12 +3201,11 @@ pm_compile_node(rb_iseq_t *iseq, const pm_node_t *node, LINK_ANCHOR *const ret,
case PM_BEGIN_NODE: {
pm_begin_node_t *begin_node = (pm_begin_node_t *) node;
rb_iseq_t *child_iseq;
- LABEL *lstart = NEW_LABEL(lineno);
- LABEL *lend = NEW_LABEL(lineno);
- LABEL *lcont = NEW_LABEL(lineno);
-
if (begin_node->rescue_clause) {
+ LABEL *lstart = NEW_LABEL(lineno);
+ LABEL *lend = NEW_LABEL(lineno);
+ LABEL *lcont = NEW_LABEL(lineno);
pm_scope_node_t rescue_scope_node;
pm_scope_node_init((pm_node_t *)begin_node->rescue_clause, &rescue_scope_node, scope_node, parser);
@@ -3292,14 +3291,12 @@ pm_compile_node(rb_iseq_t *iseq, const pm_node_t *node, LINK_ANCHOR *const ret,
}
if (!begin_node->rescue_clause && !begin_node->ensure_clause) {
- ADD_LABEL(ret, lstart);
if (begin_node->statements) {
PM_COMPILE((pm_node_t *)begin_node->statements);
}
else {
PM_PUTNIL_UNLESS_POPPED;
}
- ADD_LABEL(ret, lend);
}
return;
}