Commit a57ca1b3 authored by Clément Stenac's avatar Clément Stenac

Cache last FindItem request to speed up bulk-addings

parent c3f5011d
......@@ -377,6 +377,8 @@ Playlist::Playlist( intf_thread_t *_p_intf, wxWindow *p_parent ):
return;
}
p_saved_item = NULL;
/* Update the playlist */
Rebuild();
......@@ -655,7 +657,7 @@ void Playlist::RemoveItem( int i )
/**********************************************************************
* Search functions (internal
* Search functions (internal)
**********************************************************************/
/* Find a wxItem from a playlist_item */
......@@ -667,6 +669,11 @@ wxTreeItemId Playlist::FindItem( wxTreeItemId root, playlist_item_t *p_item )
wxTreeItemId item = treectrl->GetFirstChild( root, cookie );
wxTreeItemId child;
if( p_item == p_saved_item && saved_tree_item.IsOk() )
{
return saved_tree_item;
}
p_wxcurrent = (PlaylistItem *)treectrl->GetItemData( root );
if( !p_item )
......@@ -685,6 +692,8 @@ wxTreeItemId Playlist::FindItem( wxTreeItemId root, playlist_item_t *p_item )
p_wxcurrent = (PlaylistItem *)treectrl->GetItemData( item );
if( p_wxcurrent->p_item == p_item )
{
saved_tree_item = item;
p_saved_item = p_item;
return item;
}
if( treectrl->ItemHasChildren( item ) )
......@@ -692,6 +701,8 @@ wxTreeItemId Playlist::FindItem( wxTreeItemId root, playlist_item_t *p_item )
wxTreeItemId search = FindItem( item, p_item );
if( search.IsOk() )
{
saved_tree_item = search;
p_saved_item = p_item;
return search;
}
}
......
......@@ -883,6 +883,10 @@ private:
wxTreeItemId FindItemByName( wxTreeItemId, wxString,
wxTreeItemId, vlc_bool_t *);
wxTreeItemId saved_tree_item;
playlist_item_t *p_saved_item;
/* Custom events */
void OnPlaylistEvent( wxCommandEvent& event );
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment