mirror of
https://github.com/python/cpython.git
synced 2025-10-21 14:12:27 +00:00
Removed Py_PROTO and switched to ANSI C declarations in the dict
implementation. This was really to test whether my new CVS+SSH setup is more usable than the old one -- and turns out it is (for whatever reason, it was impossible to do a commit before that involved more than one directory).
This commit is contained in:
parent
637f6642f2
commit
1f5871e834
2 changed files with 48 additions and 118 deletions
|
@ -20,23 +20,23 @@ extern DL_IMPORT(PyTypeObject) PyDict_Type;
|
||||||
|
|
||||||
#define PyDict_Check(op) ((op)->ob_type == &PyDict_Type)
|
#define PyDict_Check(op) ((op)->ob_type == &PyDict_Type)
|
||||||
|
|
||||||
extern DL_IMPORT(PyObject *) PyDict_New Py_PROTO((void));
|
extern DL_IMPORT(PyObject *) PyDict_New(void);
|
||||||
extern DL_IMPORT(PyObject *) PyDict_GetItem Py_PROTO((PyObject *mp, PyObject *key));
|
extern DL_IMPORT(PyObject *) PyDict_GetItem(PyObject *mp, PyObject *key);
|
||||||
extern DL_IMPORT(int) PyDict_SetItem Py_PROTO((PyObject *mp, PyObject *key, PyObject *item));
|
extern DL_IMPORT(int) PyDict_SetItem(PyObject *mp, PyObject *key, PyObject *item);
|
||||||
extern DL_IMPORT(int) PyDict_DelItem Py_PROTO((PyObject *mp, PyObject *key));
|
extern DL_IMPORT(int) PyDict_DelItem(PyObject *mp, PyObject *key);
|
||||||
extern DL_IMPORT(void) PyDict_Clear Py_PROTO((PyObject *mp));
|
extern DL_IMPORT(void) PyDict_Clear(PyObject *mp);
|
||||||
extern DL_IMPORT(int) PyDict_Next
|
extern DL_IMPORT(int) PyDict_Next
|
||||||
Py_PROTO((PyObject *mp, int *pos, PyObject **key, PyObject **value));
|
(PyObject *mp, int *pos, PyObject **key, PyObject **value);
|
||||||
extern DL_IMPORT(PyObject *) PyDict_Keys Py_PROTO((PyObject *mp));
|
extern DL_IMPORT(PyObject *) PyDict_Keys(PyObject *mp);
|
||||||
extern DL_IMPORT(PyObject *) PyDict_Values Py_PROTO((PyObject *mp));
|
extern DL_IMPORT(PyObject *) PyDict_Values(PyObject *mp);
|
||||||
extern DL_IMPORT(PyObject *) PyDict_Items Py_PROTO((PyObject *mp));
|
extern DL_IMPORT(PyObject *) PyDict_Items(PyObject *mp);
|
||||||
extern DL_IMPORT(int) PyDict_Size Py_PROTO((PyObject *mp));
|
extern DL_IMPORT(int) PyDict_Size(PyObject *mp);
|
||||||
extern DL_IMPORT(PyObject *) PyDict_Copy Py_PROTO((PyObject *mp));
|
extern DL_IMPORT(PyObject *) PyDict_Copy(PyObject *mp);
|
||||||
|
|
||||||
|
|
||||||
extern DL_IMPORT(PyObject *) PyDict_GetItemString Py_PROTO((PyObject *dp, char *key));
|
extern DL_IMPORT(PyObject *) PyDict_GetItemString(PyObject *dp, char *key);
|
||||||
extern DL_IMPORT(int) PyDict_SetItemString Py_PROTO((PyObject *dp, char *key, PyObject *item));
|
extern DL_IMPORT(int) PyDict_SetItemString(PyObject *dp, char *key, PyObject *item);
|
||||||
extern DL_IMPORT(int) PyDict_DelItemString Py_PROTO((PyObject *dp, char *key));
|
extern DL_IMPORT(int) PyDict_DelItemString(PyObject *dp, char *key);
|
||||||
|
|
||||||
#ifdef __cplusplus
|
#ifdef __cplusplus
|
||||||
}
|
}
|
||||||
|
|
|
@ -130,12 +130,8 @@ All arithmetic on hash should ignore overflow.
|
||||||
(This version is due to Reimer Behrends, some ideas are also due to
|
(This version is due to Reimer Behrends, some ideas are also due to
|
||||||
Jyrki Alakuijala and Vladimir Marangozov.)
|
Jyrki Alakuijala and Vladimir Marangozov.)
|
||||||
*/
|
*/
|
||||||
static dictentry *lookdict Py_PROTO((dictobject *, PyObject *, long));
|
|
||||||
static dictentry *
|
static dictentry *
|
||||||
lookdict(mp, key, hash)
|
lookdict(dictobject *mp, PyObject *key, register long hash)
|
||||||
dictobject *mp;
|
|
||||||
PyObject *key;
|
|
||||||
register long hash;
|
|
||||||
{
|
{
|
||||||
register int i;
|
register int i;
|
||||||
register unsigned incr;
|
register unsigned incr;
|
||||||
|
@ -199,14 +195,8 @@ Internal routine to insert a new item into the table.
|
||||||
Used both by the internal resize routine and by the public insert routine.
|
Used both by the internal resize routine and by the public insert routine.
|
||||||
Eats a reference to key and one to value.
|
Eats a reference to key and one to value.
|
||||||
*/
|
*/
|
||||||
static void insertdict
|
|
||||||
Py_PROTO((dictobject *, PyObject *, long, PyObject *));
|
|
||||||
static void
|
static void
|
||||||
insertdict(mp, key, hash, value)
|
insertdict(register dictobject *mp, PyObject *key, long hash, PyObject *value)
|
||||||
register dictobject *mp;
|
|
||||||
PyObject *key;
|
|
||||||
long hash;
|
|
||||||
PyObject *value;
|
|
||||||
{
|
{
|
||||||
PyObject *old_value;
|
PyObject *old_value;
|
||||||
register dictentry *ep;
|
register dictentry *ep;
|
||||||
|
@ -234,11 +224,8 @@ Restructure the table by allocating a new table and reinserting all
|
||||||
items again. When entries have been deleted, the new table may
|
items again. When entries have been deleted, the new table may
|
||||||
actually be smaller than the old one.
|
actually be smaller than the old one.
|
||||||
*/
|
*/
|
||||||
static int dictresize Py_PROTO((dictobject *, int));
|
|
||||||
static int
|
static int
|
||||||
dictresize(mp, minused)
|
dictresize(dictobject *mp, int minused)
|
||||||
dictobject *mp;
|
|
||||||
int minused;
|
|
||||||
{
|
{
|
||||||
register int oldsize = mp->ma_size;
|
register int oldsize = mp->ma_size;
|
||||||
register int newsize, newpoly;
|
register int newsize, newpoly;
|
||||||
|
@ -287,9 +274,7 @@ dictresize(mp, minused)
|
||||||
}
|
}
|
||||||
|
|
||||||
PyObject *
|
PyObject *
|
||||||
PyDict_GetItem(op, key)
|
PyDict_GetItem(PyObject *op, PyObject *key)
|
||||||
PyObject *op;
|
|
||||||
PyObject *key;
|
|
||||||
{
|
{
|
||||||
long hash;
|
long hash;
|
||||||
if (!PyDict_Check(op)) {
|
if (!PyDict_Check(op)) {
|
||||||
|
@ -312,10 +297,7 @@ PyDict_GetItem(op, key)
|
||||||
}
|
}
|
||||||
|
|
||||||
int
|
int
|
||||||
PyDict_SetItem(op, key, value)
|
PyDict_SetItem(register PyObject *op, PyObject *key, PyObject *value)
|
||||||
register PyObject *op;
|
|
||||||
PyObject *key;
|
|
||||||
PyObject *value;
|
|
||||||
{
|
{
|
||||||
register dictobject *mp;
|
register dictobject *mp;
|
||||||
register long hash;
|
register long hash;
|
||||||
|
@ -360,9 +342,7 @@ PyDict_SetItem(op, key, value)
|
||||||
}
|
}
|
||||||
|
|
||||||
int
|
int
|
||||||
PyDict_DelItem(op, key)
|
PyDict_DelItem(PyObject *op, PyObject *key)
|
||||||
PyObject *op;
|
|
||||||
PyObject *key;
|
|
||||||
{
|
{
|
||||||
register dictobject *mp;
|
register dictobject *mp;
|
||||||
register long hash;
|
register long hash;
|
||||||
|
@ -403,8 +383,7 @@ PyDict_DelItem(op, key)
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
PyDict_Clear(op)
|
PyDict_Clear(PyObject *op)
|
||||||
PyObject *op;
|
|
||||||
{
|
{
|
||||||
int i, n;
|
int i, n;
|
||||||
register dictentry *table;
|
register dictentry *table;
|
||||||
|
@ -426,11 +405,7 @@ PyDict_Clear(op)
|
||||||
}
|
}
|
||||||
|
|
||||||
int
|
int
|
||||||
PyDict_Next(op, ppos, pkey, pvalue)
|
PyDict_Next(PyObject *op, int *ppos, PyObject **pkey, PyObject **pvalue)
|
||||||
PyObject *op;
|
|
||||||
int *ppos;
|
|
||||||
PyObject **pkey;
|
|
||||||
PyObject **pvalue;
|
|
||||||
{
|
{
|
||||||
int i;
|
int i;
|
||||||
register dictobject *mp;
|
register dictobject *mp;
|
||||||
|
@ -455,8 +430,7 @@ PyDict_Next(op, ppos, pkey, pvalue)
|
||||||
/* Methods */
|
/* Methods */
|
||||||
|
|
||||||
static void
|
static void
|
||||||
dict_dealloc(mp)
|
dict_dealloc(register dictobject *mp)
|
||||||
register dictobject *mp;
|
|
||||||
{
|
{
|
||||||
register int i;
|
register int i;
|
||||||
register dictentry *ep;
|
register dictentry *ep;
|
||||||
|
@ -478,10 +452,7 @@ dict_dealloc(mp)
|
||||||
}
|
}
|
||||||
|
|
||||||
static int
|
static int
|
||||||
dict_print(mp, fp, flags)
|
dict_print(register dictobject *mp, register FILE *fp, register int flags)
|
||||||
register dictobject *mp;
|
|
||||||
register FILE *fp;
|
|
||||||
register int flags;
|
|
||||||
{
|
{
|
||||||
register int i;
|
register int i;
|
||||||
register int any;
|
register int any;
|
||||||
|
@ -518,8 +489,7 @@ dict_print(mp, fp, flags)
|
||||||
}
|
}
|
||||||
|
|
||||||
static PyObject *
|
static PyObject *
|
||||||
dict_repr(mp)
|
dict_repr(dictobject *mp)
|
||||||
dictobject *mp;
|
|
||||||
{
|
{
|
||||||
auto PyObject *v;
|
auto PyObject *v;
|
||||||
PyObject *sepa, *colon;
|
PyObject *sepa, *colon;
|
||||||
|
@ -555,16 +525,13 @@ dict_repr(mp)
|
||||||
}
|
}
|
||||||
|
|
||||||
static int
|
static int
|
||||||
dict_length(mp)
|
dict_length(dictobject *mp)
|
||||||
dictobject *mp;
|
|
||||||
{
|
{
|
||||||
return mp->ma_used;
|
return mp->ma_used;
|
||||||
}
|
}
|
||||||
|
|
||||||
static PyObject *
|
static PyObject *
|
||||||
dict_subscript(mp, key)
|
dict_subscript(dictobject *mp, register PyObject *key)
|
||||||
dictobject *mp;
|
|
||||||
register PyObject *key;
|
|
||||||
{
|
{
|
||||||
PyObject *v;
|
PyObject *v;
|
||||||
long hash;
|
long hash;
|
||||||
|
@ -590,9 +557,7 @@ dict_subscript(mp, key)
|
||||||
}
|
}
|
||||||
|
|
||||||
static int
|
static int
|
||||||
dict_ass_sub(mp, v, w)
|
dict_ass_sub(dictobject *mp, PyObject *v, PyObject *w)
|
||||||
dictobject *mp;
|
|
||||||
PyObject *v, *w;
|
|
||||||
{
|
{
|
||||||
if (w == NULL)
|
if (w == NULL)
|
||||||
return PyDict_DelItem((PyObject *)mp, v);
|
return PyDict_DelItem((PyObject *)mp, v);
|
||||||
|
@ -607,9 +572,7 @@ static PyMappingMethods dict_as_mapping = {
|
||||||
};
|
};
|
||||||
|
|
||||||
static PyObject *
|
static PyObject *
|
||||||
dict_keys(mp, args)
|
dict_keys(register dictobject *mp, PyObject *args)
|
||||||
register dictobject *mp;
|
|
||||||
PyObject *args;
|
|
||||||
{
|
{
|
||||||
register PyObject *v;
|
register PyObject *v;
|
||||||
register int i, j;
|
register int i, j;
|
||||||
|
@ -630,9 +593,7 @@ dict_keys(mp, args)
|
||||||
}
|
}
|
||||||
|
|
||||||
static PyObject *
|
static PyObject *
|
||||||
dict_values(mp, args)
|
dict_values(register dictobject *mp, PyObject *args)
|
||||||
register dictobject *mp;
|
|
||||||
PyObject *args;
|
|
||||||
{
|
{
|
||||||
register PyObject *v;
|
register PyObject *v;
|
||||||
register int i, j;
|
register int i, j;
|
||||||
|
@ -653,9 +614,7 @@ dict_values(mp, args)
|
||||||
}
|
}
|
||||||
|
|
||||||
static PyObject *
|
static PyObject *
|
||||||
dict_items(mp, args)
|
dict_items(register dictobject *mp, PyObject *args)
|
||||||
register dictobject *mp;
|
|
||||||
PyObject *args;
|
|
||||||
{
|
{
|
||||||
register PyObject *v;
|
register PyObject *v;
|
||||||
register int i, j;
|
register int i, j;
|
||||||
|
@ -685,9 +644,7 @@ dict_items(mp, args)
|
||||||
}
|
}
|
||||||
|
|
||||||
static PyObject *
|
static PyObject *
|
||||||
dict_update(mp, args)
|
dict_update(register dictobject *mp, PyObject *args)
|
||||||
register dictobject *mp;
|
|
||||||
PyObject *args;
|
|
||||||
{
|
{
|
||||||
register int i;
|
register int i;
|
||||||
dictobject *other;
|
dictobject *other;
|
||||||
|
@ -718,9 +675,7 @@ dict_update(mp, args)
|
||||||
}
|
}
|
||||||
|
|
||||||
static PyObject *
|
static PyObject *
|
||||||
dict_copy(mp, args)
|
dict_copy(register dictobject *mp, PyObject *args)
|
||||||
register dictobject *mp;
|
|
||||||
PyObject *args;
|
|
||||||
{
|
{
|
||||||
if (!PyArg_Parse(args, ""))
|
if (!PyArg_Parse(args, ""))
|
||||||
return NULL;
|
return NULL;
|
||||||
|
@ -728,8 +683,7 @@ dict_copy(mp, args)
|
||||||
}
|
}
|
||||||
|
|
||||||
PyObject *
|
PyObject *
|
||||||
PyDict_Copy(o)
|
PyDict_Copy(PyObject *o)
|
||||||
PyObject *o;
|
|
||||||
{
|
{
|
||||||
register dictobject *mp;
|
register dictobject *mp;
|
||||||
register int i;
|
register int i;
|
||||||
|
@ -761,8 +715,7 @@ PyDict_Copy(o)
|
||||||
}
|
}
|
||||||
|
|
||||||
int
|
int
|
||||||
PyDict_Size(mp)
|
PyDict_Size(PyObject *mp)
|
||||||
PyObject *mp;
|
|
||||||
{
|
{
|
||||||
if (mp == NULL || !PyDict_Check(mp)) {
|
if (mp == NULL || !PyDict_Check(mp)) {
|
||||||
PyErr_BadInternalCall();
|
PyErr_BadInternalCall();
|
||||||
|
@ -772,8 +725,7 @@ PyDict_Size(mp)
|
||||||
}
|
}
|
||||||
|
|
||||||
PyObject *
|
PyObject *
|
||||||
PyDict_Keys(mp)
|
PyDict_Keys(PyObject *mp)
|
||||||
PyObject *mp;
|
|
||||||
{
|
{
|
||||||
if (mp == NULL || !PyDict_Check(mp)) {
|
if (mp == NULL || !PyDict_Check(mp)) {
|
||||||
PyErr_BadInternalCall();
|
PyErr_BadInternalCall();
|
||||||
|
@ -783,8 +735,7 @@ PyDict_Keys(mp)
|
||||||
}
|
}
|
||||||
|
|
||||||
PyObject *
|
PyObject *
|
||||||
PyDict_Values(mp)
|
PyDict_Values(PyObject *mp)
|
||||||
PyObject *mp;
|
|
||||||
{
|
{
|
||||||
if (mp == NULL || !PyDict_Check(mp)) {
|
if (mp == NULL || !PyDict_Check(mp)) {
|
||||||
PyErr_BadInternalCall();
|
PyErr_BadInternalCall();
|
||||||
|
@ -794,8 +745,7 @@ PyDict_Values(mp)
|
||||||
}
|
}
|
||||||
|
|
||||||
PyObject *
|
PyObject *
|
||||||
PyDict_Items(mp)
|
PyDict_Items(PyObject *mp)
|
||||||
PyObject *mp;
|
|
||||||
{
|
{
|
||||||
if (mp == NULL || !PyDict_Check(mp)) {
|
if (mp == NULL || !PyDict_Check(mp)) {
|
||||||
PyErr_BadInternalCall();
|
PyErr_BadInternalCall();
|
||||||
|
@ -813,10 +763,7 @@ PyDict_Items(mp)
|
||||||
pval argument. No reference counts are incremented. */
|
pval argument. No reference counts are incremented. */
|
||||||
|
|
||||||
static PyObject *
|
static PyObject *
|
||||||
characterize(a, b, pval)
|
characterize(dictobject *a, dictobject *b, PyObject **pval)
|
||||||
dictobject *a;
|
|
||||||
dictobject *b;
|
|
||||||
PyObject **pval;
|
|
||||||
{
|
{
|
||||||
PyObject *diff = NULL;
|
PyObject *diff = NULL;
|
||||||
int i;
|
int i;
|
||||||
|
@ -843,8 +790,7 @@ characterize(a, b, pval)
|
||||||
}
|
}
|
||||||
|
|
||||||
static int
|
static int
|
||||||
dict_compare(a, b)
|
dict_compare(dictobject *a, dictobject *b)
|
||||||
dictobject *a, *b;
|
|
||||||
{
|
{
|
||||||
PyObject *adiff, *bdiff, *aval, *bval;
|
PyObject *adiff, *bdiff, *aval, *bval;
|
||||||
int res;
|
int res;
|
||||||
|
@ -873,8 +819,7 @@ dict_compare(a, b)
|
||||||
#else /* !NEWCMP */
|
#else /* !NEWCMP */
|
||||||
|
|
||||||
static int
|
static int
|
||||||
dict_compare(a, b)
|
dict_compare(dictobject *a, dictobject *b)
|
||||||
dictobject *a, *b;
|
|
||||||
{
|
{
|
||||||
PyObject *akeys, *bkeys;
|
PyObject *akeys, *bkeys;
|
||||||
int i, n, res;
|
int i, n, res;
|
||||||
|
@ -952,9 +897,7 @@ dict_compare(a, b)
|
||||||
#endif /* !NEWCMP */
|
#endif /* !NEWCMP */
|
||||||
|
|
||||||
static PyObject *
|
static PyObject *
|
||||||
dict_has_key(mp, args)
|
dict_has_key(register dictobject *mp, PyObject *args)
|
||||||
register dictobject *mp;
|
|
||||||
PyObject *args;
|
|
||||||
{
|
{
|
||||||
PyObject *key;
|
PyObject *key;
|
||||||
long hash;
|
long hash;
|
||||||
|
@ -975,9 +918,7 @@ dict_has_key(mp, args)
|
||||||
}
|
}
|
||||||
|
|
||||||
static PyObject *
|
static PyObject *
|
||||||
dict_get(mp, args)
|
dict_get(register dictobject *mp, PyObject *args)
|
||||||
register dictobject *mp;
|
|
||||||
PyObject *args;
|
|
||||||
{
|
{
|
||||||
PyObject *key;
|
PyObject *key;
|
||||||
PyObject *failobj = Py_None;
|
PyObject *failobj = Py_None;
|
||||||
|
@ -1009,9 +950,7 @@ dict_get(mp, args)
|
||||||
|
|
||||||
|
|
||||||
static PyObject *
|
static PyObject *
|
||||||
dict_clear(mp, args)
|
dict_clear(register dictobject *mp, PyObject *args)
|
||||||
register dictobject *mp;
|
|
||||||
PyObject *args;
|
|
||||||
{
|
{
|
||||||
if (!PyArg_NoArgs(args))
|
if (!PyArg_NoArgs(args))
|
||||||
return NULL;
|
return NULL;
|
||||||
|
@ -1058,9 +997,7 @@ static PyMethodDef mapp_methods[] = {
|
||||||
};
|
};
|
||||||
|
|
||||||
static PyObject *
|
static PyObject *
|
||||||
dict_getattr(mp, name)
|
dict_getattr(dictobject *mp, char *name)
|
||||||
dictobject *mp;
|
|
||||||
char *name;
|
|
||||||
{
|
{
|
||||||
return Py_FindMethod(mapp_methods, (PyObject *)mp, name);
|
return Py_FindMethod(mapp_methods, (PyObject *)mp, name);
|
||||||
}
|
}
|
||||||
|
@ -1095,9 +1032,7 @@ PyTypeObject PyDict_Type = {
|
||||||
/* For backward compatibility with old dictionary interface */
|
/* For backward compatibility with old dictionary interface */
|
||||||
|
|
||||||
PyObject *
|
PyObject *
|
||||||
PyDict_GetItemString(v, key)
|
PyDict_GetItemString(PyObject *v, char *key)
|
||||||
PyObject *v;
|
|
||||||
char *key;
|
|
||||||
{
|
{
|
||||||
PyObject *kv, *rv;
|
PyObject *kv, *rv;
|
||||||
kv = PyString_FromString(key);
|
kv = PyString_FromString(key);
|
||||||
|
@ -1109,10 +1044,7 @@ PyDict_GetItemString(v, key)
|
||||||
}
|
}
|
||||||
|
|
||||||
int
|
int
|
||||||
PyDict_SetItemString(v, key, item)
|
PyDict_SetItemString(PyObject *v, char *key, PyObject *item)
|
||||||
PyObject *v;
|
|
||||||
char *key;
|
|
||||||
PyObject *item;
|
|
||||||
{
|
{
|
||||||
PyObject *kv;
|
PyObject *kv;
|
||||||
int err;
|
int err;
|
||||||
|
@ -1126,9 +1058,7 @@ PyDict_SetItemString(v, key, item)
|
||||||
}
|
}
|
||||||
|
|
||||||
int
|
int
|
||||||
PyDict_DelItemString(v, key)
|
PyDict_DelItemString(PyObject *v, char *key)
|
||||||
PyObject *v;
|
|
||||||
char *key;
|
|
||||||
{
|
{
|
||||||
PyObject *kv;
|
PyObject *kv;
|
||||||
int err;
|
int err;
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue