@@ -178,7 +178,6 @@ key_get_pressed(PyObject *self, PyObject *_null)
178178#endif
179179 PyObject * ret_obj = NULL ;
180180 PyObject * key_tuple ;
181- int i ;
182181
183182 VIDEO_INIT_CHECK ();
184183
@@ -192,14 +191,8 @@ key_get_pressed(PyObject *self, PyObject *_null)
192191 return NULL ;
193192 }
194193
195- for (i = 0 ; i < num_keys ; i ++ ) {
196- PyObject * key_elem ;
197- key_elem = PyBool_FromLong (key_state [i ]);
198- if (!key_elem ) {
199- Py_DECREF (key_tuple );
200- return NULL ;
201- }
202- PyTuple_SET_ITEM (key_tuple , i , key_elem );
194+ for (int i = 0 ; i < num_keys ; i ++ ) {
195+ PyTuple_SET_ITEM (key_tuple , i , PyBool_FromLong (key_state [i ]));
203196 }
204197
205198 ret_obj =
@@ -221,15 +214,8 @@ get_just_pressed(PyObject *self, PyObject *_null)
221214 return NULL ;
222215 }
223216
224- int i ;
225- for (i = 0 ; i < SDL_NUM_SCANCODES ; i ++ ) {
226- PyObject * key_elem ;
227- key_elem = PyBool_FromLong (pressed_keys [i ]);
228- if (!key_elem ) {
229- Py_DECREF (key_tuple );
230- return NULL ;
231- }
232- PyTuple_SET_ITEM (key_tuple , i , key_elem );
217+ for (int i = 0 ; i < SDL_NUM_SCANCODES ; i ++ ) {
218+ PyTuple_SET_ITEM (key_tuple , i , PyBool_FromLong (pressed_keys [i ]));
233219 }
234220 ret_obj =
235221 PyObject_CallOneArg ((PyObject * )& pgScancodeWrapper_Type , key_tuple );
@@ -250,15 +236,8 @@ get_just_released(PyObject *self, PyObject *_null)
250236 return NULL ;
251237 }
252238
253- int i ;
254- for (i = 0 ; i < SDL_NUM_SCANCODES ; i ++ ) {
255- PyObject * key_elem ;
256- key_elem = PyBool_FromLong (released_keys [i ]);
257- if (!key_elem ) {
258- Py_DECREF (key_tuple );
259- return NULL ;
260- }
261- PyTuple_SET_ITEM (key_tuple , i , key_elem );
239+ for (int i = 0 ; i < SDL_NUM_SCANCODES ; i ++ ) {
240+ PyTuple_SET_ITEM (key_tuple , i , PyBool_FromLong (released_keys [i ]));
262241 }
263242 ret_obj =
264243 PyObject_CallOneArg ((PyObject * )& pgScancodeWrapper_Type , key_tuple );
0 commit comments