[banshee] PlayQueueSource: Fix high memory usage when shuffling (bgo#676144)
- From: Bertrand Lorentz <blorentz src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [banshee] PlayQueueSource: Fix high memory usage when shuffling (bgo#676144)
- Date: Sat, 19 May 2012 16:22:38 +0000 (UTC)
commit f5b0804d3cd5d99c836a6fe86b775926f69e9f7d
Author: Bertrand Lorentz <bertrand lorentz gmail com>
Date: Sat May 19 18:05:01 2012 +0200
PlayQueueSource: Fix high memory usage when shuffling (bgo#676144)
We were using Enumerable.Range by passing as a second parameter the
value of the last integer in the range we want. But it is in fact the
number of integers in the range.
So for example shuffling tracks with a ViewOrder between 1000 and 1003
would allocate a list of 1003 integers, instead of just the 3 we need.
.../Banshee.PlayQueue/PlayQueueSource.cs | 12 +++++++-----
1 files changed, 7 insertions(+), 5 deletions(-)
---
diff --git a/src/Extensions/Banshee.PlayQueue/Banshee.PlayQueue/PlayQueueSource.cs b/src/Extensions/Banshee.PlayQueue/Banshee.PlayQueue/PlayQueueSource.cs
index ab8113a..bfda13d 100644
--- a/src/Extensions/Banshee.PlayQueue/Banshee.PlayQueue/PlayQueueSource.cs
+++ b/src/Extensions/Banshee.PlayQueue/Banshee.PlayQueue/PlayQueueSource.cs
@@ -174,17 +174,19 @@ namespace Banshee.PlayQueue
if (current_track == null)
return;
- int enabled_count = EnabledCount;
+ int shuffle_count = EnabledCount;
int first_view_order = (int)CurrentTrackViewOrder;
- int last_view_order = first_view_order + enabled_count;
// If the current track is playing, don't shuffle it
- if (ServiceManager.PlayerEngine.IsPlaying (current_track))
+ if (ServiceManager.PlayerEngine.IsPlaying (current_track)) {
first_view_order++;
+ shuffle_count--;
+ }
// Nothing to do if less than 2 tracks
- if (last_view_order - first_view_order < 2)
+ if (shuffle_count < 2) {
return;
+ }
// Save the current_track index, so we can update the current track
// to be whatever one is at that position after we shuffle them -- assuming
@@ -194,7 +196,7 @@ namespace Banshee.PlayQueue
// Setup a function that will return a random ViewOrder in the range we want
var rand = new Random ();
var func_id = "play-queue-shuffle-order-" + rand.NextDouble ().ToString ();
- var view_orders = Enumerable.Range (first_view_order, last_view_order)
+ var view_orders = Enumerable.Range (first_view_order, shuffle_count)
.OrderBy (a => rand.NextDouble ())
.ToList ();
int i = 0;
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]