@@ -99,9 +99,9 @@ static_builtin_index_clear(PyTypeObject *self)
9999}
100100
101101static inline static_builtin_state *
102- static_builtin_state_get (PyInterpreterState * interp , size_t index )
102+ static_builtin_state_get (PyInterpreterState * interp , PyTypeObject * self )
103103{
104- return & (interp -> types .builtins [index ]);
104+ return & (interp -> types .builtins [static_builtin_index_get ( self ) ]);
105105}
106106
107107/* For static types we store some state in an array on each interpreter. */
@@ -113,23 +113,22 @@ _PyStaticType_GetState(PyTypeObject *self)
113113 return NULL ;
114114 }
115115 PyInterpreterState * interp = _PyInterpreterState_GET ();
116- return static_builtin_state_get (interp , static_builtin_index_get ( self ) );
116+ return static_builtin_state_get (interp , self );
117117}
118118
119119static void
120120static_builtin_state_init (PyTypeObject * self )
121121{
122+ /* Set the type's per-interpreter state. */
123+ PyInterpreterState * interp = _PyInterpreterState_GET ();
124+
122125 /* It should only be called once for each builtin type. */
123126 assert (!static_builtin_index_is_set (self ));
124127
125- PyInterpreterState * interp = _PyInterpreterState_GET ();
126- size_t index = interp -> types .num_builtins_initialized ;
128+ static_builtin_index_set (self , interp -> types .num_builtins_initialized );
127129 interp -> types .num_builtins_initialized ++ ;
128- static_builtin_index_set (self , index );
129130
130- /* Now we initialize the type's per-interpreter state. */
131- static_builtin_state * state = static_builtin_state_get (interp , index );
132- assert (state != NULL );
131+ static_builtin_state * state = static_builtin_state_get (interp , self );
133132 state -> type = self ;
134133}
135134
@@ -140,9 +139,7 @@ static_builtin_state_clear(PyTypeObject *self)
140139 This basically undoes what static_builtin_state_init() did. */
141140 PyInterpreterState * interp = _PyInterpreterState_GET ();
142141
143- size_t index = static_builtin_index_get (self );
144- static_builtin_state * state = static_builtin_state_get (interp , index );
145- assert (state != NULL );
142+ static_builtin_state * state = static_builtin_state_get (interp , self );
146143 state -> type = NULL ;
147144 static_builtin_index_clear (self );
148145
0 commit comments