summaryrefslogtreecommitdiff
path: root/sv.c
diff options
context:
space:
mode:
authorNicholas Clark <nick@ccl4.org>2005-12-09 18:46:17 +0000
committerNicholas Clark <nick@ccl4.org>2005-12-09 18:46:17 +0000
commitab1e7f954de0531c104e9628076d0ac3e768f895 (patch)
tree86d12507c82174f7c988907f0018ab0d50c6644f /sv.c
parent4c016c2ef1ee9644dc5f18339034f84fbe464024 (diff)
downloadperl-ab1e7f954de0531c104e9628076d0ac3e768f895.tar.gz
A more efficient way to loop in ptr_table_clear
p4raw-id: //depot/perl@26312
Diffstat (limited to 'sv.c')
-rw-r--r--sv.c19
1 files changed, 6 insertions, 13 deletions
diff --git a/sv.c b/sv.c
index f3676541aa..d4baffc0c4 100644
--- a/sv.c
+++ b/sv.c
@@ -9128,31 +9128,24 @@ void
Perl_ptr_table_clear(pTHX_ PTR_TBL_t *tbl)
{
register PTR_TBL_ENT_t **array;
- register PTR_TBL_ENT_t *entry;
UV riter = 0;
- UV max;
if (!tbl || !tbl->tbl_items) {
return;
}
array = tbl->tbl_ary;
- entry = array[0];
- max = tbl->tbl_max;
+ riter = tbl->tbl_max;
- for (;;) {
- if (entry) {
+ do {
+ PTR_TBL_ENT_t *entry = array[riter];
+
+ while (entry) {
PTR_TBL_ENT_t *oentry = entry;
entry = entry->next;
del_pte(oentry);
}
- if (!entry) {
- if (++riter > max) {
- break;
- }
- entry = array[riter];
- }
- }
+ } while (riter--);
tbl->tbl_items = 0;
}