From: Nicholas Clark Date: Thu, 12 May 2011 11:28:38 +0000 (+0100) Subject: GvNAME() is shared from 5.10 onwards. X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?a=commitdiff_plain;h=638a265a89c75e2418ddc1c87a560bb8022ea667;p=p5sagit%2FDevel-Size.git GvNAME() is shared from 5.10 onwards. --- diff --git a/CHANGES b/CHANGES index 61fcacc..b578e9e 100644 --- a/CHANGES +++ b/CHANGES @@ -3,6 +3,7 @@ Revision history for Perl extension Devel::Size. 0.76_50 2011-05-12 nicholas * Split out HEK size calculation into hek_size(). Add the shared HE overhead. * Handle shared hash key scalars correctly. + * GvNAME() is shared from 5.10 onwards. 0.76 2011-05-11 nicholas * Just fix the version number in the line below. diff --git a/Size.xs b/Size.xs index e72731e..e588b67 100644 --- a/Size.xs +++ b/Size.xs @@ -794,7 +794,11 @@ sv_size(pTHX_ struct state *const st, const SV * const orig_thing, case SVt_PVGV: TAG; if(isGV_with_GP(thing)) { +#ifdef GvNAME_HEK + hek_size(aTHX_ st, GvNAME_HEK(thing), 1); +#else st->total_size += GvNAMELEN(thing); +#endif #ifdef GvFILE_HEK hek_size(aTHX_ st, GvFILE_HEK(thing), 1); #elif defined(GvFILE) diff --git a/t/globs.t b/t/globs.t index 247bb84..ae32309 100644 --- a/t/globs.t +++ b/t/globs.t @@ -60,9 +60,18 @@ $SIG{__WARN__} = sub { my $copy = *PFLAP; my $copy_gv_size = total_size($copy); # GV copies point back to the real GV through GvEGV. They share the same GP - # and GvFILE - is($copy_gv_size, $real_gv_size + $incremental_gv_size - $gp_size, - 'GV copies point back to the real GV'); + # and GvFILE. In 5.10 and later GvNAME is also shared. + my $shared_gvname = 0; + if ($] >= 5.010) { + # Calculate the size of the shared HEK: + my %h = (PFLAP => 0); + my $shared = (keys %h)[0]; + $shared_gvname = total_size($shared); + undef $shared; + $shared_gvname-= total_size($shared); + } + is($copy_gv_size, $real_gv_size + $incremental_gv_size - $gp_size + - $shared_gvname, 'GV copies point back to the real GV'); } sub gv_grew {