This is a live mirror of the Perl 5 development currently hosted at https://github.com/perl/perl5
Make B::HV::NAME an ALIAS of B::GV::NAME, as both convert HEKs to SVs.
authorNicholas Clark <nick@ccl4.org>
Sat, 30 Oct 2010 20:29:39 +0000 (21:29 +0100)
committerNicholas Clark <nick@ccl4.org>
Sat, 30 Oct 2010 20:29:39 +0000 (21:29 +0100)
Previously B::HV::NAME was a simple XS wrapper around HvNAME(), which meant a
conversion to a char *, and then back to an SV.

ext/B/B.xs

index e3679db..96d9dc5 100644 (file)
@@ -1778,12 +1778,15 @@ GvNAME(gv)
        B::GV   gv
     ALIAS:
        FILE = 1
+       B::HV::NAME = 2
     CODE:
 #if PERL_VERSION >= 10
-       ST(0) = sv_2mortal(newSVhek(ix ? GvFILE_HEK(gv) : GvNAME_HEK(gv)));
+       ST(0) = sv_2mortal(newSVhek(!ix ? GvNAME_HEK(gv)
+                                       : (ix == 1 ? GvFILE_HEK(gv)
+                                                  : HvNAME_HEK((HV *)gv))));
 #else
-       ST(0) = ix ? sv_2mortal(newSVpv(GvFILE(gv), 0))
-           : newSVpvn_flags(GvNAME(gv), GvNAMELEN(gv), SVs_TEMP);
+       ST(0) = !ix ? newSVpvn_flags(GvNAME(gv), GvNAMELEN(gv), SVs_TEMP)
+                   : sv_2mortal(newSVpv(ix == 1 ? GvFILE(gv) : HvNAME((HV *)gv), 0))
 #endif
 
 bool
@@ -1986,10 +1989,6 @@ I32
 HvRITER(hv)
        B::HV   hv
 
-char *
-HvNAME(hv)
-       B::HV   hv
-
 #if PERL_VERSION < 9
 
 B::PMOP