[vlc-commits] dialog: use vlc_array_index_of_item

Thomas Guillem git at videolan.org
Thu Feb 23 19:56:50 CET 2017


vlc | branch: master | Thomas Guillem <thomas at gllm.fr> | Thu Feb 23 14:29:25 2017 +0100| [37a24d9cd1bef498d5e87bc28355383f5b8aa39a] | committer: Thomas Guillem

dialog: use vlc_array_index_of_item

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

 src/interface/dialog.c | 18 +++---------------
 1 file changed, 3 insertions(+), 15 deletions(-)

diff --git a/src/interface/dialog.c b/src/interface/dialog.c
index d174de1..38ec83b 100644
--- a/src/interface/dialog.c
+++ b/src/interface/dialog.c
@@ -166,17 +166,6 @@ libvlc_InternalDialogInit(libvlc_int_t *p_libvlc)
     return VLC_SUCCESS;
 }
 
-static int
-dialog_get_idx_locked(vlc_dialog_provider *p_provider, vlc_dialog_id *p_id)
-{
-    for (size_t i = 0; i < vlc_array_count(&p_provider->dialog_array); ++i)
-    {
-        if (p_id == vlc_array_item_at_index(&p_provider->dialog_array, i))
-            return i;
-    }
-    return -1;
-}
-
 static void
 dialog_cancel_locked(vlc_dialog_provider *p_provider, vlc_dialog_id *p_id)
 {
@@ -212,10 +201,9 @@ dialog_add_locked(vlc_dialog_provider *p_provider, enum dialog_type i_type)
 static void
 dialog_remove_locked(vlc_dialog_provider *p_provider, vlc_dialog_id *p_id)
 {
-    int i_array_idx = dialog_get_idx_locked(p_provider, p_id);
-    assert(i_array_idx >= 0);
-
-    vlc_array_remove(&p_provider->dialog_array, i_array_idx);
+    ssize_t i_idx = vlc_array_index_of_item(&p_provider->dialog_array, p_id);
+    assert(i_idx >= 0);
+    vlc_array_remove(&p_provider->dialog_array, i_idx);
 
     vlc_mutex_lock(&p_id->lock);
     p_id->i_refcount--;



More information about the vlc-commits mailing list