[vlc-devel] [PATCH 12/40] playlist: create a playlist node depending on item type

RĂ©mi Denis-Courmont remi at remlab.net
Sun May 14 17:45:42 CEST 2017


If the input item for the new playlist item is already of type node,
assume that the caller wants to create a new playlist node. This skips
calling ChangeToNode() later and incurred processing in interfaces.

This also enables some further code factorization.
---
 src/playlist/item.c | 2 +-
 src/playlist/tree.c | 1 -
 2 files changed, 1 insertion(+), 2 deletions(-)

diff --git a/src/playlist/item.c b/src/playlist/item.c
index 692cb1d073..08d0ff015e 100644
--- a/src/playlist/item.c
+++ b/src/playlist/item.c
@@ -249,7 +249,7 @@ playlist_item_t *playlist_ItemNewFromInput( playlist_t *p_playlist,
     p_item->p_input = p_input;
     p_item->i_id = p->i_last_playlist_id;
     p_item->p_parent = NULL;
-    p_item->i_children = -1;
+    p_item->i_children = (p_input->i_type == ITEM_TYPE_NODE) ? 0 : -1;
     p_item->pp_children = NULL;
     p_item->i_nb_played = 0;
     p_item->i_flags = 0;
diff --git a/src/playlist/tree.c b/src/playlist/tree.c
index a50c620a49..10f3be994a 100644
--- a/src/playlist/tree.c
+++ b/src/playlist/tree.c
@@ -74,7 +74,6 @@ playlist_item_t * playlist_NodeCreate( playlist_t *p_playlist,
     input_item_Release( p_new_input );
 
     if( p_item == NULL )  return NULL;
-    p_item->i_children = 0;
 
     if( p_parent != NULL )
         playlist_NodeInsert( p_parent, p_item, i_pos );
-- 
2.11.0



More information about the vlc-devel mailing list