[vlc-devel] [PATCH 1/2] Extend libvlc Media Player API for DVD menu navigation
Rémi Denis-Courmont
remi at remlab.net
Tue Sep 7 21:59:57 CEST 2010
On Tue, 7 Sep 2010 14:41:36 +0200, Arnaud Vallat <rno.rno at gmail.com>
wrote:
> + switch (navigate)
> + {
> + case libvlc_navigate_up:
> + i_key = vlc_GetActionId("key-nav-up");
> + break;
> +
> + case libvlc_navigate_down:
> + i_key = vlc_GetActionId("key-nav-down");
> + break;
> +
> + case libvlc_navigate_left:
> + i_key = vlc_GetActionId("key-nav-left");
> + break;
> +
> + case libvlc_navigate_right:
> + i_key = vlc_GetActionId("key-nav-right");
> + break;
Oh no. First you convert an integer to a string using a linear search
(switch statement).
Then you convert the string back to an integer using a binary search
(vlc_GetActionId).
How about a static constant table that maps your libvlc enum directly to
vlc_key? It's much simpler and it is O(1).
--
Rémi Denis-Courmont
http://www.remlab.net
http://fi.linkedin.com/in/remidenis
More information about the vlc-devel
mailing list