[vlc-devel] [PATCH 2/4] demux: mkv: HandleKeyEvent: use common variable initialization

Filip Roséen filip at atch.se
Sun Jul 22 08:16:33 CEST 2018


All cases are declaring an identical variable with the same
initialization, the only difference in the first few cases is that it
refers to the value using a pointer (which is unnecessary as the read
value will be the same).
---
 modules/demux/mkv/events.cpp | 24 ++++++++++--------------
 1 file changed, 10 insertions(+), 14 deletions(-)

diff --git a/modules/demux/mkv/events.cpp b/modules/demux/mkv/events.cpp
index 6357971a02..1834089bf1 100644
--- a/modules/demux/mkv/events.cpp
+++ b/modules/demux/mkv/events.cpp
@@ -181,14 +181,15 @@ void event_thread_t::HandleKeyEvent( EventInfo const& ev )
     if( i_curr_button <= 0 || i_curr_button > pci->hli.hl_gi.btn_ns )
         return;
 
+    btni_t button_ptr = pci->hli.btnit[i_curr_button-1];
+
     switch( ev.action.id )
     {
     case ACTIONID_NAV_LEFT:
         {
-            btni_t *p_button_ptr = &(pci->hli.btnit[i_curr_button-1]);
-            if ( p_button_ptr->left > 0 && p_button_ptr->left <= pci->hli.hl_gi.btn_ns )
+            if ( button_ptr.left > 0 && button_ptr.left <= pci->hli.hl_gi.btn_ns )
             {
-                i_curr_button = p_button_ptr->left;
+                i_curr_button = button_ptr.left;
                 p_sys->dvd_interpretor.SetSPRM( 0x88, i_curr_button );
                 btni_t button_ptr = pci->hli.btnit[i_curr_button-1];
                 if ( button_ptr.auto_action_mode )
@@ -207,10 +208,9 @@ void event_thread_t::HandleKeyEvent( EventInfo const& ev )
         break;
     case ACTIONID_NAV_RIGHT:
         {
-            btni_t *p_button_ptr = &(pci->hli.btnit[i_curr_button-1]);
-            if ( p_button_ptr->right > 0 && p_button_ptr->right <= pci->hli.hl_gi.btn_ns )
+            if ( button_ptr.right > 0 && button_ptr.right <= pci->hli.hl_gi.btn_ns )
             {
-                i_curr_button = p_button_ptr->right;
+                i_curr_button = button_ptr.right;
                 p_sys->dvd_interpretor.SetSPRM( 0x88, i_curr_button );
                 btni_t button_ptr = pci->hli.btnit[i_curr_button-1];
                 if ( button_ptr.auto_action_mode )
@@ -229,10 +229,9 @@ void event_thread_t::HandleKeyEvent( EventInfo const& ev )
         break;
     case ACTIONID_NAV_UP:
         {
-            btni_t *p_button_ptr = &(pci->hli.btnit[i_curr_button-1]);
-            if ( p_button_ptr->up > 0 && p_button_ptr->up <= pci->hli.hl_gi.btn_ns )
+            if ( button_ptr.up > 0 && button_ptr.up <= pci->hli.hl_gi.btn_ns )
             {
-                i_curr_button = p_button_ptr->up;
+                i_curr_button = button_ptr.up;
                 p_sys->dvd_interpretor.SetSPRM( 0x88, i_curr_button );
                 btni_t button_ptr = pci->hli.btnit[i_curr_button-1];
                 if ( button_ptr.auto_action_mode )
@@ -251,10 +250,9 @@ void event_thread_t::HandleKeyEvent( EventInfo const& ev )
         break;
     case ACTIONID_NAV_DOWN:
         {
-            btni_t *p_button_ptr = &(pci->hli.btnit[i_curr_button-1]);
-            if ( p_button_ptr->down > 0 && p_button_ptr->down <= pci->hli.hl_gi.btn_ns )
+            if ( button_ptr.down > 0 && button_ptr.down <= pci->hli.hl_gi.btn_ns )
             {
-                i_curr_button = p_button_ptr->down;
+                i_curr_button = button_ptr.down;
                 p_sys->dvd_interpretor.SetSPRM( 0x88, i_curr_button );
                 btni_t button_ptr = pci->hli.btnit[i_curr_button-1];
                 if ( button_ptr.auto_action_mode )
@@ -273,8 +271,6 @@ void event_thread_t::HandleKeyEvent( EventInfo const& ev )
         break;
     case ACTIONID_NAV_ACTIVATE:
         {
-            btni_t button_ptr = pci->hli.btnit[i_curr_button-1];
-
             vlc_mutex_unlock( &lock );
             vlc_mutex_lock( &p_sys->lock_demuxer );
 
-- 
2.18.0


More information about the vlc-devel mailing list