Skip to content

Commit

Permalink
Apply suggestion from code review
Browse files Browse the repository at this point in the history
  • Loading branch information
erlend-aasland committed Apr 17, 2024
1 parent 9ad94d3 commit b67d7bd
Showing 1 changed file with 10 additions and 2 deletions.
12 changes: 10 additions & 2 deletions Objects/typeobject.c
Original file line number Diff line number Diff line change
Expand Up @@ -116,10 +116,18 @@ type_from_ref(PyObject *ref)

/* helpers for for static builtin types */

#ifndef NDEBUG
static inline int
static_builtin_index_is_set(PyTypeObject *self)
{
return self->tp_subclasses != NULL;
}
#endif

static inline size_t
static_builtin_index_get(PyTypeObject *self)
{
assert(self->tp_subclasses != NULL);
assert(static_builtin_index_is_set(self));
/* We store a 1-based index so 0 can mean "not initialized". */
return (size_t)self->tp_subclasses - 1;
}
Expand Down Expand Up @@ -157,7 +165,7 @@ static void
static_builtin_state_init(PyInterpreterState *interp, PyTypeObject *self)
{
if (_Py_IsMainInterpreter(interp)) {
assert(self->tp_subclasses == NULL);
assert(!static_builtin_index_is_set(self));
static_builtin_index_set(self, interp->types.num_builtins_initialized);
}
else {
Expand Down

0 comments on commit b67d7bd

Please sign in to comment.