Author: nicholas
Date: Wed Dec 7 15:52:52 2005
New Revision: 369
Modified:
trunk/perl/sv.c
Log:
Move the code to find/create pointer table entries into S_ptr_table_find.
Make Perl_ptr_table_store call this.
Modified: trunk/perl/sv.c
==============================================================================
--- trunk/perl/sv.c (original)
+++ trunk/perl/sv.c Wed Dec 7 15:52:52 2005
@@ -9384,8 +9384,8 @@ Perl_ptr_table_fetch(pTHX_ PTR_TBL_t *tb
/* add a new entry to a pointer-mapping table */
-void
-Perl_ptr_table_store(pTHX_ PTR_TBL_t *tbl, void *oldv, void *newv)
+static PTR_TBL_ENT_t *
+S_ptr_table_find(pTHX_ PTR_TBL_t *tbl, void *oldv)
{
PTR_TBL_ENT_t *tblent, **otblent;
/* XXX this may be pessimal on platforms where pointers aren't good
@@ -9398,18 +9398,27 @@ Perl_ptr_table_store(pTHX_ PTR_TBL_t *tb
otblent = &tbl->tbl_ary[hash & tbl->tbl_max];
for (tblent = *otblent; tblent; empty=0, tblent = tblent->next) {
if (tblent->oldval == oldv) {
- tblent->val_u.newval = newv;
- return;
+ return tblent;
}
}
tblent = S_new_pte(aTHX);
tblent->oldval = oldv;
- tblent->val_u.newval = newv;
+ tblent->val_u.newval = 0;
tblent->next = *otblent;
*otblent = tblent;
tbl->tbl_items++;
if (!empty && tbl->tbl_items > tbl->tbl_max && !tbl->iteration_nesting)
ptr_table_split(tbl);
+ return tblent;
+}
+
+
+void
+Perl_ptr_table_store(pTHX_ PTR_TBL_t *tbl, void *oldv, void *newv)
+{
+ PTR_TBL_ENT_t *const entry = S_ptr_table_find(aTHX_ tbl, oldv);
+ assert(entry);
+ entry->val_u.newval = newv;
}
/* double the hash bucket size of an existing ptr table */