This is a live mirror of the Perl 5 development currently hosted at https://github.com/perl/perl5
hv_iterkeysv() actually creates a mortal SV for every call.
authorNicholas Clark <nick@ccl4.org>
Mon, 22 Oct 2007 12:36:16 +0000 (12:36 +0000)
committerNicholas Clark <nick@ccl4.org>
Mon, 22 Oct 2007 12:36:16 +0000 (12:36 +0000)
gv_stashsv() is just a wrapper for gv_stashpvn(), so doesn't need an
SV internally. Hence avoid creating lots of mortal SVs by using
hv_iterkey() to get the keys and lengths.
Also tweak whitespace in change 32168.

p4raw-id: //depot/perl@32169

mro.c

diff --git a/mro.c b/mro.c
index 95e0ef1..5f9bcfe 100644 (file)
--- a/mro.c
+++ b/mro.c
@@ -518,8 +518,9 @@ Perl_mro_isa_changed_in(pTHX_ HV* stash)
     if(isarev) {
         hv_iterinit(isarev);
         while((iter = hv_iternext(isarev))) {
-            SV* const revkey = hv_iterkeysv(iter);
-            HV* revstash = gv_stashsv(revkey, 0);
+           I32 len;
+            const char* const revkey = hv_iterkey(iter, &len);
+            HV* revstash = gv_stashpvn(revkey, len, 0);
             struct mro_meta* revmeta;
 
             if(!revstash) continue;
@@ -563,8 +564,8 @@ Perl_mro_isa_changed_in(pTHX_ HV* stash)
 
        if(SvTYPE(mroisarev) != SVt_PVHV) {
            SvREFCNT_dec(mroisarev);
-           mroisarev = newHV();    
-           HeVAL(he) = (SV *) mroisarev; 
+           mroisarev = newHV();
+           HeVAL(he) = (SV *)mroisarev;
         }
 
        /* This hash only ever contains PL_sv_yes. Storing it over itself is
@@ -645,8 +646,9 @@ Perl_mro_method_changed_in(pTHX_ HV *stash)
 
         hv_iterinit(isarev);
         while((iter = hv_iternext(isarev))) {
-            SV* const revkey = hv_iterkeysv(iter);
-            HV* const revstash = gv_stashsv(revkey, 0);
+           I32 len;
+            const char* const revkey = hv_iterkey(iter, &len);
+            HV* const revstash = gv_stashpvn(revkey, len, 0);
             struct mro_meta* mrometa;
 
             if(!revstash) continue;