S_mro_get_linear_isa_c3() doesn't need to call hv_fetch() then
Nicholas Clark [Mon, 22 Oct 2007 11:46:55 +0000 (11:46 +0000)]
hv_store(), as hv_fetch() can do it all for us.

p4raw-id: //depot/perl@32167

mro.c

diff --git a/mro.c b/mro.c
index ed40bdd..aca1ee8 100644 (file)
--- a/mro.c
+++ b/mro.c
@@ -313,12 +313,13 @@ S_mro_get_linear_isa_c3(pTHX_ HV* stash, I32 level)
                 SV** seq_ptr = AvARRAY(seq) + 1;
                 while(seq_items--) {
                     SV* const seqitem = *seq_ptr++;
-                    HE* const he = hv_fetch_ent(tails, seqitem, 0, 0);
-                    if(!he) {
-                        (void)hv_store_ent(tails, seqitem, newSViv(1), 0);
-                    }
-                    else {
+                   /* LVALUE fetch will create a new undefined SV if necessary
+                    */
+                    HE* const he = hv_fetch_ent(tails, seqitem, 1, 0);
+                    if(he) {
                         SV* const val = HeVAL(he);
+                       /* This will increment undef to 1, which is what we
+                          want for a newly created entry.  */
                         sv_inc(val);
                     }
                 }