[banshee] AppleDeviceSource: Improve previous commit, to dequeue, not enumerate
- From: AndrÃs Aragoneses <aaragoneses src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [banshee] AppleDeviceSource: Improve previous commit, to dequeue, not enumerate
- Date: Sun, 23 Sep 2012 16:09:18 +0000 (UTC)
commit bf1d5a9e6d90e36643bc24c6309462f376e93c58
Author: Andres G. Aragoneses <knocte gmail com>
Date: Sun Sep 23 17:09:13 2012 +0100
AppleDeviceSource: Improve previous commit, to dequeue, not enumerate
A foreach loop doesn't need a pre-Count check really. But, wait,
invalid_tracks_in_device is now a Queue like the other collections
to sync, so the proper way to do this is Dequeuing, not enumerating.
...reviewer from hell said.
NB: lock is not needed here when dequeueing because invalid tracks
cannot be added by the user on the fly while a sync happens.
.../Banshee.Dap.AppleDevice/AppleDeviceSource.cs | 12 +++++-------
1 files changed, 5 insertions(+), 7 deletions(-)
---
diff --git a/src/Dap/Banshee.Dap.AppleDevice/Banshee.Dap.AppleDevice/AppleDeviceSource.cs b/src/Dap/Banshee.Dap.AppleDevice/Banshee.Dap.AppleDevice/AppleDeviceSource.cs
index 8b5fa1d..c43d159 100644
--- a/src/Dap/Banshee.Dap.AppleDevice/Banshee.Dap.AppleDevice/AppleDeviceSource.cs
+++ b/src/Dap/Banshee.Dap.AppleDevice/Banshee.Dap.AppleDevice/AppleDeviceSource.cs
@@ -659,13 +659,11 @@ namespace Banshee.Dap.AppleDevice
void SyncRemovalOfInvalidTracks ()
{
- if (invalid_tracks_in_device.Count > 0) {
- foreach (var track in invalid_tracks_in_device) {
- try {
- DeleteTrack (track, false);
- } catch (Exception e) {
- Log.Exception ("Cannot remove invalid track from iPod", e);
- }
+ while (invalid_tracks_in_device.Count > 0) {
+ try {
+ DeleteTrack (invalid_tracks_in_device.Dequeue (), false);
+ } catch (Exception e) {
+ Log.Exception ("Cannot remove invalid track from iPod", e);
}
}
}
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]