From 4a19294ca8dcb205c8e6cd4d090eff71c756dde2 Mon Sep 17 00:00:00 2001
From: Jaime Ita Passos <jp6781615@gmail.com>
Date: Tue, 15 Nov 2022 23:45:14 -0300
Subject: [PATCH] Merge these two loops together in Controller_GetFromID

---
 src/sdl/i_gamepad.c | 11 ++---------
 1 file changed, 2 insertions(+), 9 deletions(-)

diff --git a/src/sdl/i_gamepad.c b/src/sdl/i_gamepad.c
index c3150ac6e8..69f03d662e 100644
--- a/src/sdl/i_gamepad.c
+++ b/src/sdl/i_gamepad.c
@@ -534,17 +534,10 @@ void I_SetGamepadDigital(UINT8 which, boolean enable)
 
 static gamepad_t *Controller_GetFromID(SDL_JoystickID which, UINT8 *found)
 {
-	SDL_JoystickID joyid[NUM_GAMEPADS];
-
-	UINT8 i;
-
 	// Determine the joystick IDs for each current open controller
-	for (i = 0; i < NUM_GAMEPADS; i++)
-		joyid[i] = SDL_JoystickInstanceID(controllers[i].joydev);
-
-	for (i = 0; i < NUM_GAMEPADS; i++)
+	for (UINT8 i = 0; i < NUM_GAMEPADS; i++)
 	{
-		if (which == joyid[i])
+		if (which == SDL_JoystickInstanceID(controllers[i].joydev))
 		{
 			(*found) = i;
 			return &gamepads[i];
-- 
GitLab