summaryrefslogtreecommitdiffstats
path: root/Objects/dictobject.c
diff options
context:
space:
mode:
authorVictor Stinner <victor.stinner@gmail.com>2013-07-16 20:17:26 (GMT)
committerVictor Stinner <victor.stinner@gmail.com>2013-07-16 20:17:26 (GMT)
commita9f61a5a2345b72802c8604fb4f45f06df75a719 (patch)
tree5c6dc400813ace89b0cf7c2ac9805145decf4376 /Objects/dictobject.c
parentfdcbab96024e1607a84e3ed746e2af052ca46c11 (diff)
downloadcpython-a9f61a5a2345b72802c8604fb4f45f06df75a719.zip
cpython-a9f61a5a2345b72802c8604fb4f45f06df75a719.tar.gz
cpython-a9f61a5a2345b72802c8604fb4f45f06df75a719.tar.bz2
Cleanup dictobject.c
Diffstat (limited to 'Objects/dictobject.c')
-rw-r--r--Objects/dictobject.c36
1 files changed, 19 insertions, 17 deletions
diff --git a/Objects/dictobject.c b/Objects/dictobject.c
index 99247d3..d02ef02 100644
--- a/Objects/dictobject.c
+++ b/Objects/dictobject.c
@@ -305,9 +305,9 @@ PyDict_Fini(void)
* #define USABLE_FRACTION(n) (((n) >> 1) + ((n) >> 2) - ((n) >> 3))
*/
-/* GROWTH_RATE. Growth rate upon hitting maximum load.
- * Currently set to used*2 + capacity/2.
- * This means that dicts double in size when growing without deletions,
+/* GROWTH_RATE. Growth rate upon hitting maximum load.
+ * Currently set to used*2 + capacity/2.
+ * This means that dicts double in size when growing without deletions,
* but have more head room when the number of deletions is on a par with the
* number of insertions.
* Raising this to used*4 doubles memory consumption depending on the size of
@@ -2589,23 +2589,25 @@ static PyObject *
dict_new(PyTypeObject *type, PyObject *args, PyObject *kwds)
{
PyObject *self;
+ PyDictObject *d;
assert(type != NULL && type->tp_alloc != NULL);
self = type->tp_alloc(type, 0);
- if (self != NULL) {
- PyDictObject *d = (PyDictObject *)self;
- d->ma_keys = new_keys_object(PyDict_MINSIZE_COMBINED);
- /* XXX - Should we raise a no-memory error? */
- if (d->ma_keys == NULL) {
- DK_INCREF(Py_EMPTY_KEYS);
- d->ma_keys = Py_EMPTY_KEYS;
- d->ma_values = empty_values;
- }
- d->ma_used = 0;
- /* The object has been implicitly tracked by tp_alloc */
- if (type == &PyDict_Type)
- _PyObject_GC_UNTRACK(d);
- }
+ if (self == NULL)
+ return NULL;
+
+ d = (PyDictObject *)self;
+ d->ma_keys = new_keys_object(PyDict_MINSIZE_COMBINED);
+ /* XXX - Should we raise a no-memory error? */
+ if (d->ma_keys == NULL) {
+ DK_INCREF(Py_EMPTY_KEYS);
+ d->ma_keys = Py_EMPTY_KEYS;
+ d->ma_values = empty_values;
+ }
+ d->ma_used = 0;
+ /* The object has been implicitly tracked by tp_alloc */
+ if (type == &PyDict_Type)
+ _PyObject_GC_UNTRACK(d);
return self;
}