Skip to content
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
roll back typeobject.c to main
  • Loading branch information
neonene authored Sep 22, 2024
commit af8b92c6e57115aafa0d54d94b96a4f642b0431b
20 changes: 9 additions & 11 deletions Objects/typeobject.c
Original file line number Diff line number Diff line change
Expand Up @@ -5340,25 +5340,24 @@ get_base_by_token_from_mro(PyTypeObject *type, void *token)

static int
check_base_by_token(PyTypeObject *type, void *token) {
// Chain the branches, which will be optimized exclusive here
if (token == NULL) {
PyErr_Format(PyExc_SystemError,
"PyType_GetBaseByToken called with token=NULL");
return -1;
}
if (!PyType_Check(type)) {
else if (!PyType_Check(type)) {
PyErr_Format(PyExc_TypeError,
"expected a type, got a '%T' object", type);
return -1;
}
// Ensure the flag is checked by a function, not directly. PyType_Check()
// above also uses PyType_HasFeature() instead of the internal duplicate.
if (!PyType_HasFeature(type, Py_TPFLAGS_HEAPTYPE)) {
else if (!_PyType_HasFeature(type, Py_TPFLAGS_HEAPTYPE)) {
return 0;
}
if (((PyHeapTypeObject*)type)->ht_token == token) {
else if (((PyHeapTypeObject*)type)->ht_token == token) {
return 1;
}
if (type->tp_mro != NULL) {
else if (type->tp_mro != NULL) {
// This will not be inlined
return get_base_by_token_from_mro(type, token) ? 1 : 0;
}
Expand All @@ -5375,15 +5374,14 @@ PyType_GetBaseByToken(PyTypeObject *type, void *token, PyTypeObject **result)
// branches will become trivial to optimize.
return check_base_by_token(type, token);
}
PyTypeObject *base;
// Chain the branches below (not above), which will avoid being less
// pgoptimized by MSVC together with check_base_by_token() and other
// functions, unless they have if-else statements with similar conds.
if (token == NULL || !PyType_Check(type)) {
*result = NULL;
return check_base_by_token(type, token);
}
else if (!PyType_HasFeature(type, Py_TPFLAGS_HEAPTYPE)) {

// Chain the branches, which will be optimized exclusive here
PyTypeObject *base;
if (!_PyType_HasFeature(type, Py_TPFLAGS_HEAPTYPE)) {
// No static type has a heaptype superclass,
// which is ensured by type_ready_mro().
*result = NULL;
Expand Down