In perl.git, the branch smoke-me/nicholas/merge-hv-split has been updated

<http://perl5.git.perl.org/perl.git/commitdiff/a5c297aab028fd600c251fa2b6fd5f5f4d60201d?hp=34d6d453862a4b2db2b03735dbe1083b9b659d24>

- Log -----------------------------------------------------------------
commit a5c297aab028fd600c251fa2b6fd5f5f4d60201d
Author: Nicholas Clark <[email protected]>
Date:   Thu Feb 21 20:54:48 2013 +0100

    In S_hsplit(), replace a for with a do/while, as the loop runs at least 
once.
    
    Seems pointless to check the exit condition before any iterations, when we
    know that it will always be false the first time.
-----------------------------------------------------------------------

Summary of changes:
 hv.c |    6 +++---
 1 files changed, 3 insertions(+), 3 deletions(-)

diff --git a/hv.c b/hv.c
index 9d619d0..af722f6 100644
--- 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

--
Perl5 Master Repository

Reply via email to