rygel r489 - trunk/src/plugins/tracker
- From: zeeshanak svn gnome org
- To: svn-commits-list gnome org
- Subject: rygel r489 - trunk/src/plugins/tracker
- Date: Wed, 28 Jan 2009 12:32:51 +0000 (UTC)
Author: zeeshanak
Date: Wed Jan 28 12:32:51 2009
New Revision: 489
URL: http://svn.gnome.org/viewvc/rygel?rev=489&view=rev
Log:
Refactor: Put slicing of ArrayList into a separate method.
This should really be moved to ArrayList implementation.
Modified:
trunk/src/plugins/tracker/rygel-media-tracker.vala
Modified: trunk/src/plugins/tracker/rygel-media-tracker.vala
==============================================================================
--- trunk/src/plugins/tracker/rygel-media-tracker.vala (original)
+++ trunk/src/plugins/tracker/rygel-media-tracker.vala Wed Jan 28 12:32:51 2009
@@ -214,20 +214,32 @@
} else if (offset >= child_count) {
throw new ContentDirectoryError.NO_SUCH_OBJECT ("No such object");
} else {
- // Make sure we don't go beyond the limits
- max_count %= (child_count - offset);
-
- if (max_count == 0) {
- max_count = child_count - offset;
- }
-
- children = new ArrayList<MediaObject> ();
- for (int i = 0; i < max_count; i++) {
- children.add (this.containers.get (i + (int) offset));
- }
+ children = slice_object_list (this.containers,
+ offset,
+ max_count);
}
return children;
}
+
+ private ArrayList<MediaObject> slice_object_list (
+ ArrayList<MediaObject> list,
+ uint offset,
+ uint max_count) {
+ uint total = list.size;
+
+ var slice = new ArrayList<MediaObject> ();
+
+ if (max_count == 0 || max_count > (total - offset)) {
+ max_count = total - offset;
+ }
+
+ slice = new ArrayList<MediaObject> ();
+ for (uint i = offset; i < total; i++) {
+ slice.add (list[(int) i]);
+ }
+
+ return slice;
+ }
}
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]