[vlc-commits] macosx: optimize scrollwheel code by saving 3 objc selector calls per run

Felix Paul Kühne git at videolan.org
Mon May 28 15:51:37 CEST 2012


vlc | branch: master | Felix Paul Kühne <fkuehne at videolan.org> | Mon May 28 15:51:30 2012 +0200| [d9fb60bec03044bb7bc20e9a18d52f43f940b75b] | committer: Felix Paul Kühne

macosx: optimize scrollwheel code by saving 3 objc selector calls per run

no functional change

> http://git.videolan.org/gitweb.cgi/vlc.git/?a=commit;h=d9fb60bec03044bb7bc20e9a18d52f43f940b75b
---

 modules/gui/macosx/controls.m |   23 ++++++++++++++---------
 1 file changed, 14 insertions(+), 9 deletions(-)

diff --git a/modules/gui/macosx/controls.m b/modules/gui/macosx/controls.m
index 4deced9..1570401 100644
--- a/modules/gui/macosx/controls.m
+++ b/modules/gui/macosx/controls.m
@@ -258,49 +258,54 @@
 {
     intf_thread_t * p_intf = VLCIntf;
     BOOL b_invertedEventFromDevice = NO;
+    CGFloat f_deltaY, f_deltaX = .0;
+
     if (OSX_LION)
     {
         if ([theEvent isDirectionInvertedFromDevice])
             b_invertedEventFromDevice = YES;
     }
 
-    float f_yabsvalue = [theEvent deltaY] > 0.0f ? [theEvent deltaY] : -[theEvent deltaY];
-    float f_xabsvalue = [theEvent deltaX] > 0.0f ? [theEvent deltaX] : -[theEvent deltaX];
-    int i, i_yvlckey, i_xvlckey;
+    f_deltaY = [theEvent deltaY];
+    f_deltaX = [theEvent deltaX];
+
+    CGFloat f_yabsvalue = f_deltaY > 0.0f ? f_deltaY : -f_deltaY;
+    CGFloat f_xabsvalue = f_deltaX > 0.0f ? f_deltaX : -f_deltaX;
+    int i_yvlckey, i_xvlckey;
 
     if (b_invertedEventFromDevice)
     {
-        if ([theEvent deltaY] > 0.0f)
+        if (f_deltaY > 0.0f)
             i_yvlckey = KEY_MOUSEWHEELDOWN;
         else
             i_yvlckey = KEY_MOUSEWHEELUP;
 
-        if ([theEvent deltaX] > 0.0f)
+        if (f_deltaX > 0.0f)
             i_xvlckey = KEY_MOUSEWHEELRIGHT;
         else
             i_xvlckey = KEY_MOUSEWHEELLEFT;
     }
     else
     {
-        if ([theEvent deltaY] < 0.0f)
+        if (f_deltaY < 0.0f)
             i_yvlckey = KEY_MOUSEWHEELDOWN;
         else
             i_yvlckey = KEY_MOUSEWHEELUP;
 
-        if ([theEvent deltaX] < 0.0f)
+        if (f_deltaX < 0.0f)
             i_xvlckey = KEY_MOUSEWHEELRIGHT;
         else
             i_xvlckey = KEY_MOUSEWHEELLEFT;
     }
 
     /* Send multiple key event, depending on the intensity of the event */
-    for (i = 0; i < (int)(f_yabsvalue/4.+1.) && f_yabsvalue > 0.05 ; i++)
+    for (NSUInteger i = 0; i < (int)(f_yabsvalue/4.+1.) && f_yabsvalue > 0.05 ; i++)
         var_SetInteger( p_intf->p_libvlc, "key-pressed", i_yvlckey );
 
     /* Prioritize Y event (sound volume) over X event */
     if (f_yabsvalue < 0.05)
     {
-        for (i = 0; i < (int)(f_xabsvalue/6.+1.) && f_xabsvalue > 0.05; i++)
+        for (NSUInteger i = 0; i < (int)(f_xabsvalue/6.+1.) && f_xabsvalue > 0.05; i++)
          var_SetInteger( p_intf->p_libvlc, "key-pressed", i_xvlckey );
     }
 }



More information about the vlc-commits mailing list