@@ -99,9 +99,9 @@ static_builtin_index_clear(PyTypeObject *self)
99
99
}
100
100
101
101
static inline static_builtin_state *
102
- static_builtin_state_get (PyInterpreterState * interp , size_t index )
102
+ static_builtin_state_get (PyInterpreterState * interp , PyTypeObject * self )
103
103
{
104
- return & (interp -> types .builtins [index ]);
104
+ return & (interp -> types .builtins [static_builtin_index_get ( self ) ]);
105
105
}
106
106
107
107
/* For static types we store some state in an array on each interpreter. */
@@ -113,23 +113,22 @@ _PyStaticType_GetState(PyTypeObject *self)
113
113
return NULL ;
114
114
}
115
115
PyInterpreterState * interp = _PyInterpreterState_GET ();
116
- return static_builtin_state_get (interp , static_builtin_index_get ( self ) );
116
+ return static_builtin_state_get (interp , self );
117
117
}
118
118
119
119
static void
120
120
static_builtin_state_init (PyTypeObject * self )
121
121
{
122
+ /* Set the type's per-interpreter state. */
123
+ PyInterpreterState * interp = _PyInterpreterState_GET ();
124
+
122
125
/* It should only be called once for each builtin type. */
123
126
assert (!static_builtin_index_is_set (self ));
124
127
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 );
127
129
interp -> types .num_builtins_initialized ++ ;
128
- static_builtin_index_set (self , index );
129
130
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 );
133
132
state -> type = self ;
134
133
}
135
134
@@ -140,9 +139,7 @@ static_builtin_state_clear(PyTypeObject *self)
140
139
This basically undoes what static_builtin_state_init() did. */
141
140
PyInterpreterState * interp = _PyInterpreterState_GET ();
142
141
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 );
146
143
state -> type = NULL ;
147
144
static_builtin_index_clear (self );
148
145
0 commit comments