summaryrefslogtreecommitdiff
path: root/sv.c
diff options
context:
space:
mode:
authorNicholas Clark <nick@ccl4.org>2009-08-08 10:20:40 +0100
committerNicholas Clark <nick@ccl4.org>2009-08-08 14:14:42 +0100
commit1776cbe8523bf67a0626da7b721abaf9f0f8870a (patch)
tree399d0911956e707a0fe23a08e9ce936a08106091 /sv.c
parent4d0a25002d260ca3ae716f2f0be258eb5d040c74 (diff)
downloadperl-1776cbe8523bf67a0626da7b721abaf9f0f8870a.tar.gz
Move the "types are equal" early return ahead of the COW-removal.
Diffstat (limited to 'sv.c')
-rw-r--r--sv.c15
1 files changed, 12 insertions, 3 deletions
diff --git a/sv.c b/sv.c
index a22316c72a..a5a3554337 100644
--- a/sv.c
+++ b/sv.c
@@ -1185,13 +1185,22 @@ Perl_sv_upgrade(pTHX_ register SV *const sv, svtype new_type)
PERL_ARGS_ASSERT_SV_UPGRADE;
+ if (old_type == new_type)
+ return;
+
+ /* This clause was purposefully added ahead of the early return above to
+ the shared string hackery for (sort {$a <=> $b} keys %hash), with the
+ inference by Nick I-S that it would fix other troublesome cases. See
+ changes 7162, 7163 (f130fd4589cf5fbb24149cd4db4137c8326f49c1 and parent)
+
+ Given that shared hash key scalars are no longer PVIV, but PV, there is
+ no longer need to unshare so as to free up the IVX slot for its proper
+ purpose. So it's safe to move the early return earlier. */
+
if (new_type != SVt_PV && SvIsCOW(sv)) {
sv_force_normal_flags(sv, 0);
}
- if (old_type == new_type)
- return;
-
old_body = SvANY(sv);
/* Copying structures onto other structures that have been neatly zeroed