In S_hsplit(), replace a for with a do/while, as the loop runs at least once.
authorNicholas Clark <nick@ccl4.org>
Thu, 21 Feb 2013 19:54:48 +0000 (20:54 +0100)
committerNicholas Clark <nick@ccl4.org>
Tue, 26 Feb 2013 15:00:20 +0000 (16:00 +0100)
Seems pointless to check the exit condition before any iterations, when we
know that it will always be false the first time.

hv.c

index 9d619d0..af722f6 100644 (file)
--- a/hv.c
+++ b/hv.c
@@ -1100,7 +1100,7 @@ STATIC void
 S_hsplit(pTHX_ HV *hv, STRLEN const oldsize, STRLEN newsize)
 {
     dVAR;
-    STRLEN i;
+    STRLEN i = 0;
     char *a = (char*) HvARRAY(hv);
     HE **aep;
 
@@ -1129,7 +1129,7 @@ S_hsplit(pTHX_ HV *hv, STRLEN const oldsize, STRLEN newsize)
         return;
 
     aep = (HE**)a;
-    for (i=0; i<oldsize; i++) {
+    do {
        HE **oentry = aep + i;
        HE *entry = aep[i];
 
@@ -1147,7 +1147,7 @@ S_hsplit(pTHX_ HV *hv, STRLEN const oldsize, STRLEN newsize)
            }
            entry = *oentry;
        } while (entry);
-    }
+    } while (i++ < oldsize);
 }
 
 void