Improve description of the -s switch.
[p5sagit/p5-mst-13.2.git] / hv.c
diff --git a/hv.c b/hv.c
index 5ae5078..8ac9fb8 100644 (file)
--- a/hv.c
+++ b/hv.c
@@ -1,7 +1,7 @@
 /*    hv.c
  *
  *    Copyright (C) 1991, 1992, 1993, 1994, 1995, 1996, 1997, 1998, 1999,
- *    2000, 2001, 2002, 2003, 2004, 2005, by Larry Wall and others
+ *    2000, 2001, 2002, 2003, 2004, 2005, 2006, by Larry Wall and others
  *
  *    You may distribute under the terms of either the GNU General Public
  *    License or the Artistic License, as specified in the README file.
@@ -1610,17 +1610,14 @@ Perl_hv_clear_placeholders(pTHX_ HV *hv)
        /* Loop down the linked list heads  */
        bool first = 1;
        HE **oentry = &(HvARRAY(hv))[i];
-       HE *entry = *oentry;
-
-       if (!entry)
-           continue;
+       HE *entry;
 
-       for (; entry; entry = *oentry) {
+       while ((entry = *oentry)) {
            if (HeVAL(entry) == &PL_sv_placeholder) {
                *oentry = HeNEXT(entry);
                if (first && !*oentry)
                    HvFILL(hv)--; /* This linked list is now empty.  */
-               if (HvEITER_get(hv))
+               if (entry == HvEITER_get(hv))
                    HvLAZYDEL_on(hv);
                else
                    hv_free_ent(hv, entry);
@@ -1677,15 +1674,14 @@ S_hfreeentries(pTHX_ HV *hv)
           it's the original array.  (Hopefully there will only be 1 time
           round) */
        HE **array = HvARRAY(hv);
-       register HE *entry;
-       I32 riter = 0;
-       I32 max = HvMAX(hv);
+       I32 i = HvMAX(hv);
 
        /* Because we have taken xhv_name out, the only allocated pointer
           in the aux structure that might exist is the backreference array.
        */
 
        if (SvOOK(hv)) {
+           HE *entry;
            struct xpvhv_aux *iter = HvAUX(hv);
            /* If there are weak references to this HV, we need to avoid
               freeing them up here.  In particular we need to keep the AV
@@ -1729,19 +1725,17 @@ S_hfreeentries(pTHX_ HV *hv)
        HvFILL(hv) = 0;
        ((XPVHV*) SvANY(hv))->xhv_keys = 0;
 
-       entry = array[0];
-       for (;;) {
-           if (entry) {
+
+       do {
+           /* Loop down the linked list heads  */
+           HE *entry = array[i];
+
+           while (entry) {
                register HE * const oentry = entry;
                entry = HeNEXT(entry);
                hv_free_ent(hv, oentry);
            }
-           if (!entry) {
-               if (++riter > max)
-                   break;
-               entry = array[riter];
-           }
-       }
+       } while (--i >= 0);
 
        /* As there are no allocated pointers in the aux structure, it's now
           safe to free the array we just cleaned up, if it's not the one we're
@@ -2263,7 +2257,7 @@ S_unshare_hek_or_pvn(pTHX_ const HEK *hek, const char *str, I32 len, U32 hash)
     bool is_utf8 = FALSE;
     int k_flags = 0;
     const char * const save = str;
-    struct shared_he *he = 0;
+    struct shared_he *he = NULL;
 
     if (hek) {
        /* Find the shared he which is just before us in memory.  */