[Python-checkins] python/dist/src/Objects dictobject.c,2.152,2.153
rhettinger at users.sourceforge.net
rhettinger at users.sourceforge.net
Sun Mar 7 23:19:04 EST 2004
Update of /cvsroot/python/python/dist/src/Objects
In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv15868
Modified Files:
dictobject.c
Log Message:
Factor out code common to PyDict_Copy() and PyDict_Merge().
Index: dictobject.c
===================================================================
RCS file: /cvsroot/python/python/dist/src/Objects/dictobject.c,v
retrieving revision 2.152
retrieving revision 2.153
diff -C2 -d -r2.152 -r2.153
*** dictobject.c 4 Mar 2004 08:25:44 -0000 2.152
--- dictobject.c 8 Mar 2004 04:19:01 -0000 2.153
***************
*** 1243,1250 ****
PyDict_Copy(PyObject *o)
{
! register dictobject *mp;
! register int i;
! dictobject *copy;
! dictentry *entry;
if (o == NULL || !PyDict_Check(o)) {
--- 1243,1247 ----
PyDict_Copy(PyObject *o)
{
! PyObject *copy;
if (o == NULL || !PyDict_Check(o)) {
***************
*** 1252,1273 ****
return NULL;
}
! mp = (dictobject *)o;
! copy = (dictobject *)PyDict_New();
if (copy == NULL)
return NULL;
! if (mp->ma_used > 0) {
! if (dictresize(copy, mp->ma_used*2) != 0)
! return NULL;
! for (i = 0; i <= mp->ma_mask; i++) {
! entry = &mp->ma_table[i];
! if (entry->me_value != NULL) {
! Py_INCREF(entry->me_key);
! Py_INCREF(entry->me_value);
! insertdict(copy, entry->me_key, entry->me_hash,
! entry->me_value);
! }
! }
! }
! return (PyObject *)copy;
}
--- 1249,1259 ----
return NULL;
}
! copy = PyDict_New();
if (copy == NULL)
return NULL;
! if (PyDict_Merge(copy, o, 1) == 0)
! return copy;
! Py_DECREF(copy);
! return copy;
}
More information about the Python-checkins
mailing list