[svn:ponie] r378 - trunk/perl

[email protected] 9 Dec 2005 19:25:57 -0000
Newsgroups perl.ponie.changes
Message-ID <[email protected]>
Author: nicholas
Date: Fri Dec  9 11:25:56 2005
New Revision: 378

Modified:
   trunk/perl/sv.c
Log:
Merge changes 26312 and 26313 from blead, which improve the code in
ptr_table_clear.


Modified: trunk/perl/sv.c
==============================================================================
--- trunk/perl/sv.c	(original)
+++ trunk/perl/sv.c	Fri Dec  9 11:25:56 2005
@@ -9518,35 +9518,22 @@ S_ptr_table_cleanup(pTHX_ PTR_TBL_t *tbl
 void
 Perl_ptr_table_clear(pTHX_ PTR_TBL_t *tbl)
 {
-    register PTR_TBL_ENT_t **array;
-    register PTR_TBL_ENT_t *entry;
-    register PTR_TBL_ENT_t *oentry = Null(PTR_TBL_ENT_t*);
-    UV riter = 0;
-    UV max;
+    if (tbl && tbl->tbl_items) {
+	register PTR_TBL_ENT_t **array = tbl->tbl_ary;
+	UV riter = tbl->tbl_max;
 
-    if (!tbl || !tbl->tbl_items) {
-        return;
-    }
+	do {
+	    PTR_TBL_ENT_t *entry = array[riter];
 
-    array = tbl->tbl_ary;
-    entry = array[0];
-    max = tbl->tbl_max;
+	    while (entry) {
+		PTR_TBL_ENT_t *oentry = entry;
+		entry = entry->next;
+		S_del_pte(aTHX_ oentry);
+	    }
+	} while (riter--);
 
-    for (;;) {
-        if (entry) {
-            oentry = entry;
-            entry = entry->next;
-            S_del_pte(aTHX_ oentry);
-        }
-        if (!entry) {
-            if (++riter > max) {
-                break;
-            }
-            entry = array[riter];
-        }
+	tbl->tbl_items = 0;
     }
-
-    tbl->tbl_items = 0;
 }
 
 /* clear and free a ptr table */