Change 25415 by [EMAIL PROTECTED] on 2005/09/14 17:41:36

        Integrate:
        [ 24921]
        weak references aren't UVs, do don't show this in the dump flags.
        
        [ 24924]
        Avoid having NULL entries in the weakref backreference array, and
        make S_sv_add_backref O(1) (instead of O(n))

Affected files ...

... //depot/maint-5.8/perl/dump.c#35 integrate
... //depot/maint-5.8/perl/sv.c#138 integrate

Differences ...

==== //depot/maint-5.8/perl/dump.c#35 (text) ====
Index: perl/dump.c
--- perl/dump.c#34~25391~       Mon Sep 12 12:50:36 2005
+++ perl/dump.c Wed Sep 14 10:41:36 2005
@@ -1069,7 +1069,7 @@
        /* FALL THROUGH */
     default:
        if (SvEVALED(sv))       sv_catpv(d, "EVALED,");
-       if (SvIsUV(sv))         sv_catpv(d, "IsUV,");
+       if (SvIsUV(sv) && !(flags & SVf_ROK))   sv_catpv(d, "IsUV,");
        break;
     case SVt_PVBM:
        if (SvTAIL(sv))         sv_catpv(d, "TAIL,");

==== //depot/maint-5.8/perl/sv.c#138 (text) ====
Index: perl/sv.c
--- perl/sv.c#137~25396~        Mon Sep 12 15:33:56 2005
+++ perl/sv.c   Wed Sep 14 10:41:36 2005
@@ -4911,13 +4911,6 @@
         * by magic_killbackrefs() when tsv is being freed */
     }
     if (AvFILLp(av) >= AvMAX(av)) {
-        I32 i;
-        SV **svp = AvARRAY(av);
-        for (i = AvFILLp(av); i >= 0; i--)
-            if (!svp[i]) {
-                svp[i] = sv;        /* reuse the slot */
-                return;
-            }
         av_extend(av, AvFILLp(av)+1);
     }
     AvARRAY(av)[++AvFILLp(av)] = sv; /* av_push() */
@@ -4939,8 +4932,23 @@
        Perl_croak(aTHX_ "panic: del_backref");
     av = (AV *)mg->mg_obj;
     svp = AvARRAY(av);
-    for (i = AvFILLp(av); i >= 0; i--)
-       if (svp[i] == sv) svp[i] = Nullsv;
+    /* We shouldn't be in here more than once, but for paranoia reasons lets
+       not assume this.  */
+    for (i = AvFILLp(av); i >= 0; i--) {
+       if (svp[i] == sv) {
+           const SSize_t fill = AvFILLp(av);
+           if (i != fill) {
+               /* We weren't the last entry.
+                  An unordered list has this property that you can take the
+                  last element off the end to fill the hole, and it's still
+                  an unordered list :-)
+               */
+               svp[i] = svp[fill];
+           }
+           svp[fill] = Nullsv;
+           AvFILLp(av) = fill - 1;
+       }
+    }
 }
 
 /*
End of Patch.

Reply via email to