[vlc-commits] playlist: delete array earlier during destruction
Rémi Denis-Courmont
git at videolan.org
Fri Nov 18 21:40:16 CET 2016
vlc | branch: master | Rémi Denis-Courmont <remi at remlab.net> | Fri Nov 18 22:29:20 2016 +0200| [800448a3667a9eb3076f88bdcb8a5d03542de309] | committer: Rémi Denis-Courmont
playlist: delete array earlier during destruction
Remove items from the arrays takes time, especially during playlist
destruction. In particular removing an item from the current array
requires a linear search and then a memmove(); that was the bottleneck
with quadratic complexity while deleting the playlist. (Now the
bottleneck is removing items from their parent.)
Destroying the arrays early on skips those steps entirely.
> http://git.videolan.org/gitweb.cgi/vlc.git/?a=commit;h=800448a3667a9eb3076f88bdcb8a5d03542de309
---
src/playlist/engine.c | 7 ++++---
1 file changed, 4 insertions(+), 3 deletions(-)
diff --git a/src/playlist/engine.c b/src/playlist/engine.c
index dc5eff2..9068f19 100644
--- a/src/playlist/engine.c
+++ b/src/playlist/engine.c
@@ -328,6 +328,10 @@ void playlist_Destroy( playlist_t *p_playlist )
/* Release the current item */
set_current_status_item( p_playlist, NULL );
+ /* Destroy arrays completely - faster than one item at a time */
+ ARRAY_RESET( p_playlist->items );
+ ARRAY_RESET( p_playlist->current );
+
/* Remove all remaining items */
playlist_NodeDelete( p_playlist, p_playlist->p_root, true );
PL_UNLOCK;
@@ -335,9 +339,6 @@ void playlist_Destroy( playlist_t *p_playlist )
vlc_cond_destroy( &p_sys->signal );
vlc_mutex_destroy( &p_sys->lock );
- ARRAY_RESET( p_playlist->items );
- ARRAY_RESET( p_playlist->current );
-
vlc_http_cookie_jar_t *cookies = var_GetAddress( p_playlist, "http-cookies" );
if ( cookies )
{
More information about the vlc-commits
mailing list