diff options
author | Christian Heimes <christian@cheimes.de> | 2008-02-06 13:33:44 +0000 |
---|---|---|
committer | Christian Heimes <christian@cheimes.de> | 2008-02-06 13:33:44 +0000 |
commit | 6c8232b8e97d2dd10d64a59904b94207c5aa3751 (patch) | |
tree | 5f352a895e1177954c476a3819c5d2a98d5038e4 /Objects/setobject.c | |
parent | 77d29ebdd46ecf1afe930abc74a12a938dac1f6b (diff) | |
download | cpython-6c8232b8e97d2dd10d64a59904b94207c5aa3751.tar.gz |
Unified naming convention for free lists and their limits. All free lists
in Object/ are named ``free_list``, the counter ``numfree`` and the upper
limit is a macro ``PyName_MAXFREELIST`` inside an #ifndef block.
The chances should make it easier to adjust Python for platforms with
less memory, e.g. mobile phones.
Diffstat (limited to 'Objects/setobject.c')
-rw-r--r-- | Objects/setobject.c | 22 |
1 files changed, 12 insertions, 10 deletions
diff --git a/Objects/setobject.c b/Objects/setobject.c index 53d284f6cc..cc2c2ee868 100644 --- a/Objects/setobject.c +++ b/Objects/setobject.c @@ -51,9 +51,11 @@ _PySet_Dummy(void) } while(0) /* Reuse scheme to save calls to malloc, free, and memset */ -#define MAXFREESETS 80 -static PySetObject *free_sets[MAXFREESETS]; -static int num_free_sets = 0; +#ifndef PySet_MAXFREELIST +#define PySet_MAXFREELIST 80 +#endif +static PySetObject *free_list[PySet_MAXFREELIST]; +static int numfree = 0; /* The basic lookup function used by all operations. @@ -558,8 +560,8 @@ set_dealloc(PySetObject *so) } if (so->table != so->smalltable) PyMem_DEL(so->table); - if (num_free_sets < MAXFREESETS && PyAnySet_CheckExact(so)) - free_sets[num_free_sets++] = so; + if (numfree < PySet_MAXFREELIST && PyAnySet_CheckExact(so)) + free_list[numfree++] = so; else Py_TYPE(so)->tp_free(so); Py_TRASHCAN_SAFE_END(so) @@ -983,9 +985,9 @@ make_new_set(PyTypeObject *type, PyObject *iterable) } /* create PySetObject structure */ - if (num_free_sets && + if (numfree && (type == &PySet_Type || type == &PyFrozenSet_Type)) { - so = free_sets[--num_free_sets]; + so = free_list[--numfree]; assert (so != NULL && PyAnySet_CheckExact(so)); Py_TYPE(so) = type; _Py_NewReference((PyObject *)so); @@ -1053,9 +1055,9 @@ PySet_Fini(void) { PySetObject *so; - while (num_free_sets) { - num_free_sets--; - so = free_sets[num_free_sets]; + while (numfree) { + numfree--; + so = free_list[numfree]; PyObject_GC_Del(so); } Py_CLEAR(dummy); |