[Python-checkins] cpython: Use struct member (ht_type) instead of casting pointers.

antoine.pitrou python-checkins at python.org
Sun Jun 24 00:24:04 CEST 2012


http://hg.python.org/cpython/rev/7ce45e2625c3
changeset: 77655:7ce45e2625c3
parent: 77652:fae226a1d3c4
user: Antoine Pitrou <solipsis at pitrou.net>
date: Sun Jun 24 00:18:27 2012 +0200
summary:
 Use struct member (ht_type) instead of casting pointers.
files:
 Objects/typeobject.c | 28 ++++++++++++++--------------
 1 files changed, 14 insertions(+), 14 deletions(-)
diff --git a/Objects/typeobject.c b/Objects/typeobject.c
--- a/Objects/typeobject.c
+++ b/Objects/typeobject.c
@@ -2394,14 +2394,15 @@
 s++;
 
 if (res == NULL)
- return NULL;
+ return NULL;
+ type = &res->ht_type;
 res->ht_name = PyUnicode_FromString(s);
 if (!res->ht_name)
 goto fail;
 res->ht_qualname = res->ht_name;
 Py_INCREF(res->ht_qualname);
- res->ht_type.tp_name = spec->name;
- if (!res->ht_type.tp_name)
+ type->tp_name = spec->name;
+ if (!type->tp_name)
 goto fail;
 
 /* Adjust for empty tuple bases */
@@ -2436,7 +2437,6 @@
 goto fail;
 }
 
- type = (PyTypeObject *)res;
 /* Initialize essential fields */
 type->tp_as_number = &res->as_number;
 type->tp_as_sequence = &res->as_sequence;
@@ -2448,9 +2448,9 @@
 Py_INCREF(base);
 type->tp_base = base;
 
- res->ht_type.tp_basicsize = spec->basicsize;
- res->ht_type.tp_itemsize = spec->itemsize;
- res->ht_type.tp_flags = spec->flags | Py_TPFLAGS_HEAPTYPE;
+ type->tp_basicsize = spec->basicsize;
+ type->tp_itemsize = spec->itemsize;
+ type->tp_flags = spec->flags | Py_TPFLAGS_HEAPTYPE;
 
 for (slot = spec->slots; slot->slot; slot++) {
 if (slot->slot >= Py_ARRAY_LENGTH(slotoffsets)) {
@@ -2470,20 +2470,20 @@
 if (tp_doc == NULL)
 goto fail;
 memcpy(tp_doc, slot->pfunc, len);
- res->ht_type.tp_doc = tp_doc;
+ type->tp_doc = tp_doc;
 }
 }
- if (res->ht_type.tp_dictoffset) {
+ if (type->tp_dictoffset) {
 res->ht_cached_keys = _PyDict_NewKeysForClass();
 }
- if (res->ht_type.tp_dealloc == NULL) {
+ if (type->tp_dealloc == NULL) {
 /* It's a heap type, so needs the heap types' dealloc.
 subtype_dealloc will call the base type's tp_dealloc, if
 necessary. */
- res->ht_type.tp_dealloc = subtype_dealloc;
- }
-
- if (PyType_Ready(&res->ht_type) < 0)
+ type->tp_dealloc = subtype_dealloc;
+ }
+
+ if (PyType_Ready(type) < 0)
 goto fail;
 
 /* Set type.__module__ */
-- 
Repository URL: http://hg.python.org/cpython


More information about the Python-checkins mailing list

AltStyle によって変換されたページ (->オリジナル) /