[banshee] [ArtworkManager] Cache null artwork for fast lookup



commit 768c76da611a990054ff0921f24d566de86ac749
Author: Gabriel Burt <gabriel burt gmail com>
Date:   Wed Nov 17 12:37:55 2010 -0600

    [ArtworkManager] Cache null artwork for fast lookup

 .../Banshee.Collection.Gui/ArtworkManager.cs       |   15 +++++++++++++++
 1 files changed, 15 insertions(+), 0 deletions(-)
---
diff --git a/src/Core/Banshee.ThickClient/Banshee.Collection.Gui/ArtworkManager.cs b/src/Core/Banshee.ThickClient/Banshee.Collection.Gui/ArtworkManager.cs
index 2414ca1..cba8ec8 100644
--- a/src/Core/Banshee.ThickClient/Banshee.Collection.Gui/ArtworkManager.cs
+++ b/src/Core/Banshee.ThickClient/Banshee.Collection.Gui/ArtworkManager.cs
@@ -49,6 +49,7 @@ namespace Banshee.Collection.Gui
     {
         private Dictionary<int, SurfaceCache> scale_caches  = new Dictionary<int, SurfaceCache> ();
         private HashSet<int> cacheable_cover_sizes = new HashSet<int> ();
+        private HashSet<string> null_artwork_ids = new HashSet<string> ();
 
         private class SurfaceCache : LruCache<string, Cairo.ImageSurface>
         {
@@ -116,8 +117,13 @@ namespace Banshee.Collection.Gui
                 return surface;
             }
 
+            if (null_artwork_ids.Contains (id)) {
+                return null;
+            }
+
             Pixbuf pixbuf = LookupScalePixbuf (id, size);
             if (pixbuf == null || pixbuf.Handle == IntPtr.Zero) {
+                null_artwork_ids.Add (id);
                 return null;
             }
 
@@ -157,12 +163,17 @@ namespace Banshee.Collection.Gui
                 return null;
             }
 
+            if (null_artwork_ids.Contains (id)) {
+                return null;
+            }
+
             // Find the scaled, cached file
             string path = CoverArtSpec.GetPathForSize (id, size);
             if (File.Exists (new SafeUri (path))) {
                 try {
                     return new Pixbuf (path);
                 } catch {
+                    null_artwork_ids.Add (id);
                     return null;
                 }
             }
@@ -179,6 +190,7 @@ namespace Banshee.Collection.Gui
                         Pixbuf pixbuf = new Pixbuf (unconverted_path);
                         if (pixbuf.Width < 50 || pixbuf.Height < 50) {
                             Hyena.Log.DebugFormat ("Ignoring cover art {0} because less than 50x50", unconverted_path);
+                            null_artwork_ids.Add (id);
                             return null;
                         }
 
@@ -219,6 +231,7 @@ namespace Banshee.Collection.Gui
                 } catch {}
             }
 
+            null_artwork_ids.Add (id);
             return null;
         }
 
@@ -238,6 +251,8 @@ namespace Banshee.Collection.Gui
                 scale_caches[size].Remove (id);
             }
 
+            null_artwork_ids.Remove (id);
+
             if (inMemoryCacheOnly) {
                 return;
             }



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