From: Nicholas Clark Date: Sat, 8 Aug 2009 09:20:40 +0000 (+0100) Subject: Move the "types are equal" early return ahead of the COW-removal. X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?a=commitdiff_plain;h=1776cbe8523bf67a0626da7b721abaf9f0f8870a;p=p5sagit%2Fp5-mst-13.2.git Move the "types are equal" early return ahead of the COW-removal. --- diff --git a/sv.c b/sv.c index a22316c..a5a3554 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