From 795801b1f50cdf912b5786b74d825b2b9dd5dac9 Mon Sep 17 00:00:00 2001
From: twinaphex <libretro@gmail.com>
Date: Wed, 26 Feb 2020 05:58:11 +0100
Subject: [PATCH] Reduce amount of calls to input_event_get_osk_ptr

---
 retroarch.c | 21 ++++++++++++---------
 1 file changed, 12 insertions(+), 9 deletions(-)

diff --git a/retroarch.c b/retroarch.c
index 3cbf6d7091..e8debeefe4 100644
--- a/retroarch.c
+++ b/retroarch.c
@@ -14961,28 +14961,31 @@ static unsigned menu_event(
 
       if (BIT256_GET_PTR(p_trigger_input, RETRO_DEVICE_ID_JOYPAD_DOWN))
       {
-         if (input_event_get_osk_ptr() < 33)
-            input_event_set_osk_ptr(input_event_get_osk_ptr()
-                  + OSK_CHARS_PER_LINE);
+         int old_osk_ptr = input_event_get_osk_ptr();
+         if (old_osk_ptr < 33)
+            input_event_set_osk_ptr(old_osk_ptr + OSK_CHARS_PER_LINE);
       }
 
       if (BIT256_GET_PTR(p_trigger_input, RETRO_DEVICE_ID_JOYPAD_UP))
       {
-         if (input_event_get_osk_ptr() >= OSK_CHARS_PER_LINE)
-            input_event_set_osk_ptr(input_event_get_osk_ptr()
+         int old_osk_ptr = input_event_get_osk_ptr();
+         if (old_osk_ptr >= OSK_CHARS_PER_LINE)
+            input_event_set_osk_ptr(old_osk_ptr
                   - OSK_CHARS_PER_LINE);
       }
 
       if (BIT256_GET_PTR(p_trigger_input, RETRO_DEVICE_ID_JOYPAD_RIGHT))
       {
-         if (input_event_get_osk_ptr() < 43)
-            input_event_set_osk_ptr(input_event_get_osk_ptr() + 1);
+         int old_osk_ptr = input_event_get_osk_ptr();
+         if (old_osk_ptr < 43)
+            input_event_set_osk_ptr(old_osk_ptr + 1);
       }
 
       if (BIT256_GET_PTR(p_trigger_input, RETRO_DEVICE_ID_JOYPAD_LEFT))
       {
-         if (input_event_get_osk_ptr() >= 1)
-            input_event_set_osk_ptr(input_event_get_osk_ptr() - 1);
+         int old_osk_ptr = input_event_get_osk_ptr();
+         if (old_osk_ptr >= 1)
+            input_event_set_osk_ptr(old_osk_ptr - 1);
       }
 
       if (BIT256_GET_PTR(p_trigger_input, RETRO_DEVICE_ID_JOYPAD_L))