Change 34214 by [EMAIL PROTECTED] on 2008/08/22 06:10:31

        In S_mro_get_linear_isa_dfs(), hv_exists_ent() followed by an optional
        hv_store_ent() can be replaced with an lvalue fetch.

Affected files ...

... //depot/perl/mro.c#48 edit

Differences ...

==== //depot/perl/mro.c#48 (text) ====
Index: perl/mro.c
--- perl/mro.c#47~33901~        2008-05-21 06:35:43.000000000 -0700
+++ perl/mro.c  2008-08-21 23:10:31.000000000 -0700
@@ -185,9 +185,18 @@
            }
            while(subrv_items--) {
                SV *const subsv = *subrv_p++;
-               if(!hv_exists_ent(stored, subsv, 0)) {
-                   (void)hv_store_ent(stored, subsv, &PL_sv_undef, 0);
-                   av_push(retval, newSVsv(subsv));
+               /* LVALUE fetch will create a new undefined SV if necessary
+                */
+               HE *const he = hv_fetch_ent(stored, subsv, 1, 0);
+               assert(he);
+               if(HeVAL(he) != &PL_sv_undef) {
+                   /* It was newly created.  Steal it for our new SV, and
+                      replace it in the hash with the "real" thing.  */
+                   SV *const val = HeVAL(he);
+
+                   HeVAL(he) = &PL_sv_undef;
+                   sv_setsv(val, subsv);
+                   av_push(retval, val);
                }
             }
         }
End of Patch.

Reply via email to