Skip to content

Commit fade5e8

Browse files
committed
Use pointer directly as key.
1 parent b99223c commit fade5e8

File tree

1 file changed

+7
-12
lines changed

1 file changed

+7
-12
lines changed

graalpython/com.oracle.graal.python.cext/src/typeobject.c

Lines changed: 7 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -57,24 +57,19 @@ int PyType_IsSubtype(PyTypeObject* a, PyTypeObject* b) {
5757
}
5858

5959
static int add_subclass(PyTypeObject *base, PyTypeObject *type) {
60-
void* key = PyLong_FromVoidPtr((void *) type);
60+
void* key = (void *) type;
6161
if (key == NULL) {
6262
return -1;
6363
}
64-
if (polyglot_is_value(base)) {
65-
return polyglot_as_i32(polyglot_invoke(PY_TRUFFLE_CEXT, "PyTruffle_Add_Subclass", native_to_java((PyObject*)base), native_to_java(key), native_to_java((PyObject*)type)));
66-
} else {
67-
PyObject *dict = base->tp_subclasses;
64+
PyObject *dict = base->tp_subclasses;
65+
if (dict == NULL) {
66+
base->tp_subclasses = dict = PyDict_New();
6867
if (dict == NULL) {
69-
base->tp_subclasses = dict = PyDict_New();
70-
if (dict == NULL) {
71-
return -1;
72-
}
68+
return -1;
7369
}
74-
// TODO value should be a weak reference !
75-
return PyDict_SetItem(base->tp_subclasses, key, (PyObject*)type);
7670
}
77-
return -1;
71+
// TODO value should be a weak reference !
72+
return PyDict_SetItem(base->tp_subclasses, key, (PyObject*)type);
7873
}
7974

8075
/* Special C landing functions that convert some arguments to primitives. */

0 commit comments

Comments
 (0)