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 ): ...@@ -377,6 +377,8 @@ Playlist::Playlist( intf_thread_t *_p_intf, wxWindow *p_parent ):
return; return;
} }
p_saved_item = NULL;
/* Update the playlist */ /* Update the playlist */
Rebuild(); Rebuild();
...@@ -650,12 +652,12 @@ void Playlist::RemoveItem( int i ) ...@@ -650,12 +652,12 @@ void Playlist::RemoveItem( int i )
if( item.IsOk() ) if( item.IsOk() )
{ {
treectrl->Delete( item ); treectrl->Delete( item );
} }
} }
/********************************************************************** /**********************************************************************
* Search functions (internal * Search functions (internal)
**********************************************************************/ **********************************************************************/
/* Find a wxItem from a playlist_item */ /* Find a wxItem from a playlist_item */
...@@ -667,6 +669,11 @@ wxTreeItemId Playlist::FindItem( wxTreeItemId root, playlist_item_t *p_item ) ...@@ -667,6 +669,11 @@ wxTreeItemId Playlist::FindItem( wxTreeItemId root, playlist_item_t *p_item )
wxTreeItemId item = treectrl->GetFirstChild( root, cookie ); wxTreeItemId item = treectrl->GetFirstChild( root, cookie );
wxTreeItemId child; wxTreeItemId child;
if( p_item == p_saved_item && saved_tree_item.IsOk() )
{
return saved_tree_item;
}
p_wxcurrent = (PlaylistItem *)treectrl->GetItemData( root ); p_wxcurrent = (PlaylistItem *)treectrl->GetItemData( root );
if( !p_item ) if( !p_item )
...@@ -685,6 +692,8 @@ wxTreeItemId Playlist::FindItem( wxTreeItemId root, playlist_item_t *p_item ) ...@@ -685,6 +692,8 @@ wxTreeItemId Playlist::FindItem( wxTreeItemId root, playlist_item_t *p_item )
p_wxcurrent = (PlaylistItem *)treectrl->GetItemData( item ); p_wxcurrent = (PlaylistItem *)treectrl->GetItemData( item );
if( p_wxcurrent->p_item == p_item ) if( p_wxcurrent->p_item == p_item )
{ {
saved_tree_item = item;
p_saved_item = p_item;
return item; return item;
} }
if( treectrl->ItemHasChildren( item ) ) if( treectrl->ItemHasChildren( item ) )
...@@ -692,6 +701,8 @@ wxTreeItemId Playlist::FindItem( wxTreeItemId root, playlist_item_t *p_item ) ...@@ -692,6 +701,8 @@ wxTreeItemId Playlist::FindItem( wxTreeItemId root, playlist_item_t *p_item )
wxTreeItemId search = FindItem( item, p_item ); wxTreeItemId search = FindItem( item, p_item );
if( search.IsOk() ) if( search.IsOk() )
{ {
saved_tree_item = search;
p_saved_item = p_item;
return search; return search;
} }
} }
......
...@@ -883,6 +883,10 @@ private: ...@@ -883,6 +883,10 @@ private:
wxTreeItemId FindItemByName( wxTreeItemId, wxString, wxTreeItemId FindItemByName( wxTreeItemId, wxString,
wxTreeItemId, vlc_bool_t *); wxTreeItemId, vlc_bool_t *);
wxTreeItemId saved_tree_item;
playlist_item_t *p_saved_item;
/* Custom events */ /* Custom events */
void OnPlaylistEvent( wxCommandEvent& event ); 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