[Banshee-List] Small performance patch 3



Hello,

Thinking about why is the rendering function call so often, i saw another quick optimization; first the playlistModel
constructor sets a anonymous delegate to reload itself when the source is changed, this makes impossible to have more
than one model instance at a time; I change that and then following the recommendations of GTK+ i detached the model
from the view before reloading the model, I was able to achieve a small performance improvement, following are some
reload times when doing a source change the big ones are when going back to the library:

without change:
Reload time: 00:00:00.5566420
Reload time: 00:00:00.0785590
Reload time: 00:00:00.4819680
Reload time: 00:00:00.0056750
Reload time: 00:00:00.0055290
Reload time: 00:00:00.5379030


with changes:
Reload time: 00:00:00.5271180
Reload time: 00:00:00.0293380
Reload time: 00:00:00.4803600
Reload time: 00:00:00.0052340
Reload time: 00:00:00.0144480
Reload time: 00:00:00.4574830

Even if it not huge, and the view appear to use most of the time rendering, i think this is a nice safe improvement to
apply. The patch contains both the SyncPlayingIter changes and the Model detaching changes; Aaron please let me now if
this is not ok with you and you prefer an independent patch.

regards,

Oscar.
? burn-sharp/.deps
? burn-sharp/.libs
? burn-sharp/glue.lo
? burn-sharp/libnautilusburnglue.la
? libbanshee/.deps
? libbanshee/.libs
? libbanshee/gst-cd-rip-0.8.lo
? libbanshee/gst-misc-0.8.lo
? libbanshee/gst-playback-0.8.lo
? libbanshee/gst-transcode-0.8.lo
? libbanshee/hal-context.lo
? libbanshee/inotify-glue.lo
? libbanshee/libbanshee.la
? libbanshee/xing/.deps
? po/.intltool-merge-cache
? src/.PlayerInterface.cs.swp
? src/.PlaylistModel.cs.swp
? src/Banshee.Base/.Source.cs.swp
Index: src/PlayerInterface.cs
===================================================================
RCS file: /cvs/gnome/banshee/src/PlayerInterface.cs,v
retrieving revision 1.147
diff -u -r1.147 PlayerInterface.cs
--- src/PlayerInterface.cs	13 Feb 2006 08:21:33 -0000	1.147
+++ src/PlayerInterface.cs	1 Mar 2006 09:51:18 -0000
@@ -1073,7 +1073,7 @@
                 UpdateViewName(args.Source);
                 
                 if(playlistModel.Count() == 0 && args.Source.Count > 0) {
-                    playlistModel.ReloadSource();
+                    playlistView.ReloadSource();
                 }
                 
                 gxml["SearchLabel"].Sensitive = args.Source.SearchEnabled;
@@ -1274,7 +1274,7 @@
             playlistView.LastPlayedColumn.Hidden = (source is AudioCdSource);
                 
             UpdateSourceView();
-                
+            playlistView.ReloadSource();    
             OnPlaylistViewSelectionChanged(playlistView.Selection, new EventArgs());
         }
         
@@ -1356,7 +1356,7 @@
         {
             if(SourceManager.ActiveSource is DapSource
                 && !(SourceManager.ActiveSource as DapSource).IsSyncing) {
-                playlistModel.ReloadSource();
+                playlistView.ReloadSource();
                 UpdateDapDiskUsageBar(SourceManager.ActiveSource as DapSource);
             }
             
@@ -1522,7 +1522,7 @@
             playlistModel.Clear();
             
             if(!searchEntry.IsQueryAvailable) {
-                playlistModel.ReloadSource();
+                playlistView.ReloadSource();
                 return;
             }
             
Index: src/PlaylistModel.cs
===================================================================
RCS file: /cvs/gnome/banshee/src/PlaylistModel.cs,v
retrieving revision 1.33
diff -u -r1.33 PlaylistModel.cs
--- src/PlaylistModel.cs	8 Feb 2006 07:39:25 -0000	1.33
+++ src/PlaylistModel.cs	1 Mar 2006 09:51:18 -0000
@@ -69,33 +69,10 @@
         {
             trackInfoQueue = new ArrayList();
             GLib.Timeout.Add(300, new GLib.TimeoutHandler(OnIdle));
-            SourceManager.ActiveSourceChanged += delegate(SourceEventArgs args) {
-                ReloadSource();
-            };
-        }
-    
-        public void SyncPlayingIter()
-        {
-            if(PlayerEngineCore.ActivePlayer.Track == null) {
-                playingIter = TreeIter.Zero;
-            } else {
-                for(int i = 0, n = Count(); i < n; i++) {
-                    TreeIter iter;
-                    if(!IterNthChild(out iter, i))
-                        continue;
-                        
-                    TrackInfo ti = IterTrackInfo(iter);
-                    
-                    if(PlayerEngineCore.ActivePlayer.Track.Equals(ti)) {
-                        playingIter = iter;
-                        break;
-                    }
-                }
-            }
         }
     
         // --- Load Queue and Additions ---
-    
+
         private bool OnIdle()
         {
             QueueSync();
@@ -114,7 +91,7 @@
 
             trackInfoQueue.Clear();
             trackInfoQueueLocked = false;
-            SyncPlayingIter();
+            //SyncPlayingIter();
             
             return;
         }
@@ -134,6 +111,7 @@
         {
             AddTrack(ti, true);
         }
+
         
         public void AddTrack(TrackInfo ti, bool raiseUpdate)
         {
@@ -155,8 +133,6 @@
             foreach(TrackInfo track in SourceManager.ActiveSource.Tracks) {
                 AddTrack(track);
             }
-            
-            SyncPlayingIter();
         }
 
         // --- Helper Methods ---
@@ -418,8 +394,11 @@
             }
         }
         
-        public TreeIter PlayingIter
-        {
+        public TreeIter PlayingIter {
+			set {
+				playingIter = value;
+			}
+
             get {
                 return playingIter;
             }
Index: src/PlaylistView.cs
===================================================================
RCS file: /cvs/gnome/banshee/src/PlaylistView.cs,v
retrieving revision 1.39
diff -u -r1.39 PlaylistView.cs
--- src/PlaylistView.cs	8 Feb 2006 07:39:25 -0000	1.39
+++ src/PlaylistView.cs	1 Mar 2006 09:51:18 -0000
@@ -338,15 +338,17 @@
         protected void TrackCellInd(TreeViewColumn tree_column,
             CellRenderer cell, TreeModel tree_model, TreeIter iter)
         {
-            CellRendererPixbuf renderer = (CellRendererPixbuf)cell;
-            TrackInfo ti = model.IterTrackInfo(iter);
-            if(ti == null) {
-                return;
+            TrackInfo ti = tree_model.GetValue(iter, 0) as TrackInfo;
+            if((ti != null) && (PlayerEngineCore.ActivePlayer.Track != null)) {
+                CellRendererPixbuf renderer = (CellRendererPixbuf) cell;
+                if(PlayerEngineCore.ActivePlayer.Track.Equals(ti)) {
+                    renderer.Pixbuf = nowPlayingPixbuf;
+					model.PlayingIter = iter;
+					//Console.WriteLine("PayingIter set to: {0}", tree_model.GetStringFromIter(iter));
+                } else {
+                    renderer.Pixbuf = ti.CanPlay ? null : songDrmedPixbuf;
+                }
             }
-            
-            renderer.Pixbuf = iter.Equals(model.PlayingIter)
-                ? nowPlayingPixbuf
-                : (ti.CanPlay ? null : songDrmedPixbuf);
         }
         
         protected void RipCellInd(TreeViewColumn tree_column, CellRenderer cell, 
@@ -469,11 +471,18 @@
         
         public void UpdateView()
         {
-            model.SyncPlayingIter();
             QueueDraw();
             ScrollToPlaying();
         }
         
+		public void ReloadSource() 
+		{
+			PlaylistModel model = Model as PlaylistModel;
+			Model = null;
+			model.ReloadSource();
+			Model = model;
+		}
+
         public void ThreadedQueueDraw()
         {
             Application.Invoke(delegate {


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]