[vlc-commits] playlist/item: utilize TAB_FIND in ItemIndex
Filip Roséen
git at videolan.org
Mon Oct 10 18:43:44 CEST 2016
vlc | branch: master | Filip Roséen <filip at atch.se> | Mon Oct 10 18:17:58 2016 +0200| [2c7cb4565e601f271e9dd3c744f234febb4a3586] | committer: Thomas Guillem
playlist/item: utilize TAB_FIND in ItemIndex
Even though this results in more lines than the previous
implementation, it should be easier to read and reason about the
implementation using the already defined helper for finding entities
within a vlc TAB.
Signed-off-by: Thomas Guillem <thomas at gllm.fr>
> http://git.videolan.org/gitweb.cgi/vlc.git/?a=commit;h=2c7cb4565e601f271e9dd3c744f234febb4a3586
---
src/playlist/item.c | 11 ++++++++---
1 file changed, 8 insertions(+), 3 deletions(-)
diff --git a/src/playlist/item.c b/src/playlist/item.c
index e5ac372..d2b6272 100644
--- a/src/playlist/item.c
+++ b/src/playlist/item.c
@@ -653,9 +653,14 @@ playlist_item_t *playlist_ItemFindFromInputAndRoot( playlist_t *p_playlist,
static int ItemIndex ( playlist_item_t *p_item )
{
- for( int i = 0; i < p_item->p_parent->i_children; i++ )
- if( p_item->p_parent->pp_children[i] == p_item ) return i;
- return -1;
+ int idx;
+
+ TAB_FIND( p_item->p_parent->i_children,
+ p_item->p_parent->pp_children,
+ p_item,
+ idx );
+
+ return idx;
}
/**
More information about the vlc-commits
mailing list