core: Search inside child before checking it
authorZeeshan Ali (Khattak) <zeeshanak@gnome.org>
Thu, 5 Nov 2009 15:25:55 +0000 (17:25 +0200)
committerZeeshan Ali (Khattak) <zeeshanak@gnome.org>
Thu, 5 Nov 2009 15:25:55 +0000 (17:25 +0200)
Search inside child before checking if it satisfies the search criteria
itself.

src/rygel/rygel-media-container.vala

index 713a31c..0d1691f 100644 (file)
@@ -112,25 +112,24 @@ public abstract class Rygel.MediaContainer : MediaObject {
 
         var children = yield this.get_children (0, uint.MAX, cancellable);
         foreach (var child in children) {
-            if (expression.satisfied_by (child)) {
-                result.add (child);
+            if (child is MediaContainer) {
+                // First search inside the child container
+                var container = child as MediaContainer;
+                uint tmp;
+
+                var child_result = yield container.search (expression,
+                                                           0,
+                                                           0,
+                                                           out tmp,
+                                                           cancellable);
+
+                result.add_all (child_result);
             }
 
-            if (!(child is MediaContainer)) {
-                continue;
+            // Then check if child itself satisfies search criteria
+            if (expression.satisfied_by (child)) {
+                result.add (child);
             }
-
-            // Now continue the search inside the child container
-            var container = child as MediaContainer;
-            uint tmp;
-
-            var child_result = yield container.search (expression,
-                                                       0,
-                                                       0,
-                                                       out tmp,
-                                                       cancellable);
-
-            result.add_all (child_result);
         }
 
         total_matches = result.size;