[rygel] tracker: No need to create keychains on demand



commit 134abc0a565a5ff92a178bf71ad77446f1cacb82
Author: Zeeshan Ali (Khattak) <zeeshanak gnome org>
Date:   Tue Dec 22 17:34:32 2009 +0200

    tracker: No need to create keychains on demand
    
    This should give us some speed boost.

 .../tracker/rygel-tracker-item-factory.vala        |   30 +++++++++----------
 .../tracker/rygel-tracker-music-item-factory.vala  |   28 +++++++-----------
 .../rygel-tracker-picture-item-factory.vala        |   20 ++++--------
 .../tracker/rygel-tracker-search-container.vala    |    2 +-
 .../tracker/rygel-tracker-video-item-factory.vala  |   22 +++++---------
 5 files changed, 41 insertions(+), 61 deletions(-)
---
diff --git a/src/plugins/tracker/rygel-tracker-item-factory.vala b/src/plugins/tracker/rygel-tracker-item-factory.vala
index 22f37b0..acbb9c9 100644
--- a/src/plugins/tracker/rygel-tracker-item-factory.vala
+++ b/src/plugins/tracker/rygel-tracker-item-factory.vala
@@ -40,10 +40,24 @@ public abstract class Rygel.TrackerItemFactory {
     public string category;
     public string upnp_class;
 
+    public ArrayList<ArrayList<string>> key_chains;
+
     public TrackerItemFactory (string category,
                                string upnp_class) {
         this.category = category;
         this.upnp_class = upnp_class;
+
+        this.key_chains = new ArrayList<ArrayList<string>> ();
+
+        for (var i = 0; i < Metadata.LAST_KEY; i++) {
+            this.key_chains.add (new ArrayList<string> ());
+        }
+
+        this.key_chains[Metadata.FILE_NAME].add ("nfo:fileName");
+        this.key_chains[Metadata.TITLE].add ("nie:title");
+        this.key_chains[Metadata.MIME].add ("nie:mimeType");
+        this.key_chains[Metadata.SIZE].add ("nfo:fileSize");
+        this.key_chains[Metadata.DATE].add ("nie:contentCreated");
     }
 
     public virtual MediaItem create (string                 id,
@@ -71,21 +85,5 @@ public abstract class Rygel.TrackerItemFactory {
 
         return item;
     }
-
-    public virtual ArrayList<ArrayList<string>> get_metadata_key_chains () {
-        var keys = new ArrayList<ArrayList<string>> ();
-
-        for (var i = 0; i < Metadata.LAST_KEY; i++) {
-            keys.add (new ArrayList<string> ());
-        }
-
-        keys[Metadata.FILE_NAME].add ("nfo:fileName");
-        keys[Metadata.TITLE].add ("nie:title");
-        keys[Metadata.MIME].add ("nie:mimeType");
-        keys[Metadata.SIZE].add ("nfo:fileSize");
-        keys[Metadata.DATE].add ("nie:contentCreated");
-
-        return keys;
-    }
 }
 
diff --git a/src/plugins/tracker/rygel-tracker-music-item-factory.vala b/src/plugins/tracker/rygel-tracker-music-item-factory.vala
index 2745797..99b4712 100644
--- a/src/plugins/tracker/rygel-tracker-music-item-factory.vala
+++ b/src/plugins/tracker/rygel-tracker-music-item-factory.vala
@@ -40,6 +40,17 @@ public class Rygel.TrackerMusicItemFactory : Rygel.TrackerItemFactory {
 
     public TrackerMusicItemFactory () {
         base (CATEGORY, MediaItem.MUSIC_CLASS);
+
+        for (var i = this.key_chains.size; i < MusicMetadata.LAST_KEY; i++) {
+            this.key_chains.add (new ArrayList<string> ());
+        }
+
+        this.key_chains[MusicMetadata.DURATION].add ("nmm:length");
+        this.key_chains[MusicMetadata.AUDIO_ARTIST].add ("nmm:performer");
+        this.key_chains[MusicMetadata.AUDIO_ARTIST].add ("nmm:artistName");
+        this.key_chains[MusicMetadata.AUDIO_ALBUM].add ("nmm:musicAlbum");
+        this.key_chains[MusicMetadata.AUDIO_ALBUM].add ("nmm:albumTitle");
+        this.key_chains[MusicMetadata.AUDIO_TRACK_NUM].add ("nmm:trackNumber");
     }
 
     public override MediaItem create (string                 id,
@@ -62,22 +73,5 @@ public class Rygel.TrackerMusicItemFactory : Rygel.TrackerItemFactory {
 
         return item;
     }
-
-    public override ArrayList<ArrayList<string>> get_metadata_key_chains () {
-        var keys = base.get_metadata_key_chains ();
-
-        for (var i = keys.size; i < MusicMetadata.LAST_KEY; i++) {
-            keys.add (new ArrayList<string> ());
-        }
-
-        keys[MusicMetadata.DURATION].add ("nmm:length");
-        keys[MusicMetadata.AUDIO_ARTIST].add ("nmm:performer");
-        keys[MusicMetadata.AUDIO_ARTIST].add ("nmm:artistName");
-        keys[MusicMetadata.AUDIO_ALBUM].add ("nmm:musicAlbum");
-        keys[MusicMetadata.AUDIO_ALBUM].add ("nmm:albumTitle");
-        keys[MusicMetadata.AUDIO_TRACK_NUM].add ("nmm:trackNumber");
-
-        return keys;
-    }
 }
 
diff --git a/src/plugins/tracker/rygel-tracker-picture-item-factory.vala b/src/plugins/tracker/rygel-tracker-picture-item-factory.vala
index 5078ca2..737b5a2 100644
--- a/src/plugins/tracker/rygel-tracker-picture-item-factory.vala
+++ b/src/plugins/tracker/rygel-tracker-picture-item-factory.vala
@@ -38,6 +38,13 @@ public class Rygel.TrackerPictureItemFactory : Rygel.TrackerItemFactory {
 
     public TrackerPictureItemFactory () {
         base (CATEGORY, MediaItem.IMAGE_CLASS);
+
+        for (var i = this.key_chains.size; i < PictureMetadata.LAST_KEY; i++) {
+            this.key_chains.add (new ArrayList<string> ());
+        }
+
+        this.key_chains[PictureMetadata.WIDTH].add ("nfo:width");
+        this.key_chains[PictureMetadata.HEIGHT].add ("nfo:height");
     }
 
     public override MediaItem create (string                 id,
@@ -55,18 +62,5 @@ public class Rygel.TrackerPictureItemFactory : Rygel.TrackerItemFactory {
 
         return item;
     }
-
-    public override ArrayList<ArrayList<string>> get_metadata_key_chains () {
-        var keys = base.get_metadata_key_chains ();
-
-        for (var i = keys.size; i < PictureMetadata.LAST_KEY; i++) {
-            keys.add (new ArrayList<string> ());
-        }
-
-        keys[PictureMetadata.WIDTH].add ("nfo:width");
-        keys[PictureMetadata.HEIGHT].add ("nfo:height");
-
-        return keys;
-    }
 }
 
diff --git a/src/plugins/tracker/rygel-tracker-search-container.vala b/src/plugins/tracker/rygel-tracker-search-container.vala
index c9d08f5..a30d875 100644
--- a/src/plugins/tracker/rygel-tracker-search-container.vala
+++ b/src/plugins/tracker/rygel-tracker-search-container.vala
@@ -72,7 +72,7 @@ public class Rygel.TrackerSearchContainer : Rygel.MediaContainer {
                                                     false));
 
         var optional = new TrackerQueryTriplets ();
-        foreach (var chain in this.item_factory.get_metadata_key_chains ()) {
+        foreach (var chain in this.item_factory.key_chains) {
             var key = chain.last ();
             var variable = "?" + key.replace (":", "_");
 
diff --git a/src/plugins/tracker/rygel-tracker-video-item-factory.vala b/src/plugins/tracker/rygel-tracker-video-item-factory.vala
index a450ab2..680381e 100644
--- a/src/plugins/tracker/rygel-tracker-video-item-factory.vala
+++ b/src/plugins/tracker/rygel-tracker-video-item-factory.vala
@@ -39,6 +39,14 @@ public class Rygel.TrackerVideoItemFactory : Rygel.TrackerItemFactory {
 
     public TrackerVideoItemFactory () {
         base (CATEGORY, MediaItem.VIDEO_CLASS);
+
+        for (var i = this.key_chains.size; i < VideoMetadata.LAST_KEY; i++) {
+            this.key_chains.add (new ArrayList<string> ());
+        }
+
+        this.key_chains[VideoMetadata.WIDTH].add ("nfo:width");
+        this.key_chains[VideoMetadata.HEIGHT].add ("nfo:height");
+        this.key_chains[VideoMetadata.DURATION].add ("nmm:length");
     }
 
     public override MediaItem create (string                 id,
@@ -59,19 +67,5 @@ public class Rygel.TrackerVideoItemFactory : Rygel.TrackerItemFactory {
 
         return item;
     }
-
-    public override ArrayList<ArrayList<string>> get_metadata_key_chains () {
-        var keys = base.get_metadata_key_chains ();
-
-        for (var i = keys.size; i < VideoMetadata.LAST_KEY; i++) {
-            keys.add (new ArrayList<string> ());
-        }
-
-        keys[VideoMetadata.WIDTH].add ("nfo:width");
-        keys[VideoMetadata.HEIGHT].add ("nfo:height");
-        keys[VideoMetadata.DURATION].add ("nmm:length");
-
-        return keys;
-    }
 }
 



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