summaryrefslogtreecommitdiff
path: root/pp_hot.c
diff options
context:
space:
mode:
authorRichard Leach <richardleach@users.noreply.github.com>2023-02-11 00:26:39 +0000
committerRichard Leach <richardleach@users.noreply.github.com>2023-02-13 21:58:55 +0000
commitc56d7fa9134de66efe85a2fd70b28069c2629e0d (patch)
tree75213b2452440a30c219f4051a1a554659672408 /pp_hot.c
parent3249496afe65ad71b051caad311d33c4fdd43d8d (diff)
downloadperl-c56d7fa9134de66efe85a2fd70b28069c2629e0d.tar.gz
Perl_leave_adjust_stacks: don't make mortal copies of SvIMMORTAL SVs
SvIMMORTAL SVs cannot be prematurely freed and so there is no need to create a mortal copy of them. They also will not leak, so there is no need to add the SV* to the temp stack.
Diffstat (limited to 'pp_hot.c')
-rw-r--r--pp_hot.c7
1 files changed, 7 insertions, 0 deletions
diff --git a/pp_hot.c b/pp_hot.c
index 6ba4bae1c3..f4ee8dcc07 100644
--- a/pp_hot.c
+++ b/pp_hot.c
@@ -5041,6 +5041,13 @@ Perl_leave_adjust_stacks(pTHX_ SV **from_sp, SV **to_sp, U8 gimme, int pass)
}
}
}
+ else if (SvIMMORTAL(sv)){
+ /* Since SvIMMORTALs are never freed, even when their
+ * refcount drops to zero, there's no benefit in
+ * creating a mortal copy.
+ */
+ *++to_sp = sv;
+ }
else {
/* Make a mortal copy of the SV.
* The following code is the equivalent of sv_mortalcopy()