diff options
author | Christian Heimes <christian@cheimes.de> | 2008-02-06 13:33:44 (GMT) |
---|---|---|
committer | Christian Heimes <christian@cheimes.de> | 2008-02-06 13:33:44 (GMT) |
commit | 5b970ad483332dc6c5f3e84a238317d45f844421 (patch) | |
tree | 753dc573beb62ee375d27ebdb8ed58a24683dda2 /Objects/dictobject.c | |
parent | 6075a82243c7646dcdd45b424cf3e5c676f31ccf (diff) | |
download | cpython-5b970ad483332dc6c5f3e84a238317d45f844421.zip cpython-5b970ad483332dc6c5f3e84a238317d45f844421.tar.gz cpython-5b970ad483332dc6c5f3e84a238317d45f844421.tar.bz2 |
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/dictobject.c')
-rw-r--r-- | Objects/dictobject.c | 16 |
1 files changed, 9 insertions, 7 deletions
diff --git a/Objects/dictobject.c b/Objects/dictobject.c index 3b7c128..e0ac475 100644 --- a/Objects/dictobject.c +++ b/Objects/dictobject.c @@ -183,9 +183,11 @@ show_counts(void) } while(0) /* Dictionary reuse scheme to save calls to malloc, free, and memset */ -#define MAXFREEDICTS 80 -static PyDictObject *free_dicts[MAXFREEDICTS]; -static int num_free_dicts = 0; +#ifndef PyDict_MAXFREELIST +#define PyDict_MAXFREELIST 80 +#endif +static PyDictObject *free_list[PyDict_MAXFREELIST]; +static int numfree = 0; PyObject * PyDict_New(void) @@ -199,8 +201,8 @@ PyDict_New(void) Py_AtExit(show_counts); #endif } - if (num_free_dicts) { - mp = free_dicts[--num_free_dicts]; + if (numfree) { + mp = free_list[--numfree]; assert (mp != NULL); assert (Py_TYPE(mp) == &PyDict_Type); _Py_NewReference((PyObject *)mp); @@ -868,8 +870,8 @@ dict_dealloc(register PyDictObject *mp) } if (mp->ma_table != mp->ma_smalltable) PyMem_DEL(mp->ma_table); - if (num_free_dicts < MAXFREEDICTS && Py_TYPE(mp) == &PyDict_Type) - free_dicts[num_free_dicts++] = mp; + if (numfree < PyDict_MAXFREELIST && Py_TYPE(mp) == &PyDict_Type) + free_list[numfree++] = mp; else Py_TYPE(mp)->tp_free((PyObject *)mp); Py_TRASHCAN_SAFE_END(mp) |