From bae7e8addc8ff3e5675d19752d6dc2efdecb8f9d Mon Sep 17 00:00:00 2001 From: "Zeeshan Ali (Khattak)" Date: Thu, 5 Nov 2009 17:25:55 +0200 Subject: [PATCH] core: Search inside child before checking it Search inside child before checking if it satisfies the search criteria itself. --- src/rygel/rygel-media-container.vala | 31 +++++++++++++++---------------- 1 file changed, 15 insertions(+), 16 deletions(-) diff --git a/src/rygel/rygel-media-container.vala b/src/rygel/rygel-media-container.vala index 713a31c..0d1691f 100644 --- a/src/rygel/rygel-media-container.vala +++ b/src/rygel/rygel-media-container.vala @@ -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; -- 2.7.4