[rygel] media-export: Remove useless massive database call



commit e78d351fad5a734a58d9740108de0bc3104feac0
Author: Jens Georg <mail jensge org>
Date:   Sun Jul 25 14:22:32 2010 +0300

    media-export: Remove useless massive database call
    
    No need to get the id from the container and then look it up in the
    database to create another instance of the container. Just use the
    existing container.

 .../rygel-media-export-db-container.vala           |    9 +--------
 .../rygel-media-export-media-cache.vala            |   14 +++++++-------
 2 files changed, 8 insertions(+), 15 deletions(-)
---
diff --git a/src/plugins/media-export/rygel-media-export-db-container.vala b/src/plugins/media-export/rygel-media-export-db-container.vala
index 0e5f649..070826e 100644
--- a/src/plugins/media-export/rygel-media-export-db-container.vala
+++ b/src/plugins/media-export/rygel-media-export-db-container.vala
@@ -54,14 +54,7 @@ public class Rygel.MediaExport.DBContainer : MediaContainer {
                                                       uint         max_count,
                                                       Cancellable? cancellable)
                                                       throws GLib.Error {
-        var children = this.media_db.get_children (this.id,
-                                                   offset,
-                                                   max_count);
-        foreach (var child in children) {
-            child.parent = this;
-        }
-
-        return children;
+        return this.media_db.get_children (this, offset, max_count);
     }
 
     public override async MediaObjects? search (SearchExpression? expression,
diff --git a/src/plugins/media-export/rygel-media-export-media-cache.vala b/src/plugins/media-export/rygel-media-export-media-cache.vala
index 1675979..a6a7304 100644
--- a/src/plugins/media-export/rygel-media-export-media-cache.vala
+++ b/src/plugins/media-export/rygel-media-export-media-cache.vala
@@ -167,21 +167,21 @@ public class Rygel.MediaExport.MediaCache : Object {
         return exists;
     }
 
-    public MediaObjects get_children (string container_id,
-                                      long   offset,
-                                      long   max_count) throws Error {
+    public MediaObjects get_children (MediaContainer container,
+                                      long           offset,
+                                      long           max_count)
+                                      throws Error {
         MediaObjects children = new MediaObjects ();
-        var parent = get_object (container_id) as MediaContainer;
 
-        GLib.Value[] values = { container_id,
+        GLib.Value[] values = { container.id,
                                 (int64) offset,
                                 (int64) max_count };
         Database.RowCallback callback = (statement) => {
             var child_id = statement.column_text (DetailColumn.ID);
-            children.add (get_object_from_statement (parent,
+            children.add (get_object_from_statement (container,
                                                      child_id,
                                                      statement));
-            children.last () .parent_ref = parent;
+            children.last ().parent_ref = container;
 
             return true;
         };



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