[rygel] core: SimpleContainer implements find_object()
- From: Zeeshan Ali Khattak <zeeshanak src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [rygel] core: SimpleContainer implements find_object()
- Date: Thu, 12 Aug 2010 15:19:09 +0000 (UTC)
commit 93efe9fafe9a1b733b1997d965b5c58f1991f72a
Author: Zeeshan Ali (Khattak) <zeeshanak gnome org>
Date: Thu Aug 12 17:12:24 2010 +0300
core: SimpleContainer implements find_object()
The default find_object() implementation in base MediaContainer translates
find_object() to a search() query and since search() is recursive, the
whole tree under the container then gets a search() called on them so if
any of them has implemented find_object(), that implementation will never
be actually used. This is exactly what was happening in case of tracker
plugin and that was the main reason for it being so extremely slow in the
past few months.
Since most containers are SimpleContainer, this solves the problem for most
(if not all) of the plugins.
src/rygel/rygel-simple-container.vala | 23 +++++++++++++++++++++++
1 files changed, 23 insertions(+), 0 deletions(-)
---
diff --git a/src/rygel/rygel-simple-container.vala b/src/rygel/rygel-simple-container.vala
index 0a7875c..18f0542 100644
--- a/src/rygel/rygel-simple-container.vala
+++ b/src/rygel/rygel-simple-container.vala
@@ -71,4 +71,27 @@ public class Rygel.SimpleContainer : Rygel.MediaContainer {
return this.children.slice ((int) offset, (int) stop) as MediaObjects;
}
+
+ public override async MediaObject? find_object (string id,
+ Cancellable? cancellable)
+ throws Error {
+ MediaObject media_object = null;
+
+ foreach (var child in this.children) {
+ if (child.id == id) {
+ media_object = child;
+
+ break;
+ } else if (child is MediaContainer) {
+ var container = child as MediaContainer;
+
+ media_object = yield container.find_object (id, cancellable);
+ if (media_object != null) {
+ break;
+ }
+ }
+ }
+
+ return media_object;
+ }
}
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]