This is a live mirror of the Perl 5 development currently hosted at https://github.com/perl/perl5
An alternative way of structuring ptr_table_clear so that the variables
authorNicholas Clark <nick@ccl4.org>
Fri, 9 Dec 2005 19:18:32 +0000 (19:18 +0000)
committerNicholas Clark <nick@ccl4.org>
Fri, 9 Dec 2005 19:18:32 +0000 (19:18 +0000)
can be assigned to at declaration time.

p4raw-id: //depot/perl@26313

sv.c

diff --git a/sv.c b/sv.c
index d4baffc..9ed37cb 100644 (file)
--- a/sv.c
+++ b/sv.c
@@ -9127,27 +9127,22 @@ Perl_ptr_table_split(pTHX_ PTR_TBL_t *tbl)
 void
 Perl_ptr_table_clear(pTHX_ PTR_TBL_t *tbl)
 {
 void
 Perl_ptr_table_clear(pTHX_ PTR_TBL_t *tbl)
 {
-    register PTR_TBL_ENT_t **array;
-    UV riter = 0;
+    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;
-    }
-
-    array = tbl->tbl_ary;
-    riter = tbl->tbl_max;
-
-    do {
-       PTR_TBL_ENT_t *entry = array[riter];
+       do {
+           PTR_TBL_ENT_t *entry = array[riter];
 
 
-       while (entry) {
-            PTR_TBL_ENT_t *oentry = entry;
-            entry = entry->next;
-            del_pte(oentry);
-        }
-    } while (riter--);
+           while (entry) {
+               PTR_TBL_ENT_t *oentry = entry;
+               entry = entry->next;
+               del_pte(oentry);
+           }
+       } while (riter--);
 
 
-    tbl->tbl_items = 0;
+       tbl->tbl_items = 0;
+    }
 }
 
 /* clear and free a ptr table */
 }
 
 /* clear and free a ptr table */