[vlc-commits] lib/media_list: simplify libvlc_media_list_index_of_item

Filip Roséen git at videolan.org
Thu Oct 13 11:09:46 CEST 2016


vlc | branch: master | Filip Roséen <filip at atch.se> | Wed Oct 12 20:08:03 2016 +0200| [6727d548194b08b6c3e7da3655ae9661e333283c] | committer: Jean-Baptiste Kempf

lib/media_list: simplify libvlc_media_list_index_of_item

Signed-off-by: Jean-Baptiste Kempf <jb at videolan.org>

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

 lib/media_list.c | 14 +++++---------
 1 file changed, 5 insertions(+), 9 deletions(-)

diff --git a/lib/media_list.c b/lib/media_list.c
index 430fa42..e81d657 100644
--- a/lib/media_list.c
+++ b/lib/media_list.c
@@ -442,15 +442,11 @@ libvlc_media_list_item_at_index( libvlc_media_list_t * p_mlist,
 int libvlc_media_list_index_of_item( libvlc_media_list_t * p_mlist,
                                      libvlc_media_t * p_searched_md )
 {
-    libvlc_media_t * p_md;
-    for ( int i = 0; i < vlc_array_count( &p_mlist->items ); i++ )
-    {
-        p_md = vlc_array_item_at_index( &p_mlist->items, i );
-        if( p_searched_md == p_md )
-            return i;
-    }
-    libvlc_printerr( "Media not found" );
-    return -1;
+    int idx = vlc_array_index_of_item( &p_mlist->items, p_searched_md );
+    if( idx == -1 )
+        libvlc_printerr( "Media not found" );
+
+    return idx;
 }
 
 /**************************************************************************



More information about the vlc-commits mailing list