[banshee] Remove unnecessary array allocations



commit 3db01454717669b1c7903a1ae07b8db9cef84f11
Author: Alexander Kojevnikov <alexk gnome org>
Date:   Thu Dec 22 09:02:42 2011 +0800

    Remove unnecessary array allocations

 .../Banshee.Dap.MassStorage/MassStorageSource.cs   |    3 +--
 .../Banshee.Dap.Mtp/Banshee.Dap.Mtp/MtpSource.cs   |    3 +--
 .../FileSystemQueueSource.cs                       |    2 +-
 .../Banshee.Podcasting/PodcastService.cs           |    3 +--
 4 files changed, 4 insertions(+), 7 deletions(-)
---
diff --git a/src/Dap/Banshee.Dap.MassStorage/Banshee.Dap.MassStorage/MassStorageSource.cs b/src/Dap/Banshee.Dap.MassStorage/Banshee.Dap.MassStorage/MassStorageSource.cs
index 3e02c53..2ddd5dd 100644
--- a/src/Dap/Banshee.Dap.MassStorage/Banshee.Dap.MassStorage/MassStorageSource.cs
+++ b/src/Dap/Banshee.Dap.MassStorage/Banshee.Dap.MassStorage/MassStorageSource.cs
@@ -164,7 +164,6 @@ namespace Banshee.Dap.MassStorage
             if (CanSyncPlaylists) {
                 var insert_cmd = new Hyena.Data.Sqlite.HyenaSqliteCommand (
                     "INSERT INTO CorePlaylistEntries (PlaylistID, TrackID) VALUES (?, ?)");
-                int [] psources = new int [] {DbId};
                 foreach (string playlist_path in PlaylistFiles) {
                     IPlaylistFormat loaded_playlist = PlaylistFileUtil.Load (playlist_path, new Uri (PlaylistsPath));
                     if (loaded_playlist == null)
@@ -176,7 +175,7 @@ namespace Banshee.Dap.MassStorage
                     //Hyena.Data.Sqlite.HyenaSqliteCommand.LogAll = true;
                     foreach (Dictionary<string, object> element in loaded_playlist.Elements) {
                         string track_path = (element["uri"] as Uri).LocalPath;
-                        int track_id = DatabaseTrackInfo.GetTrackIdForUri (new SafeUri (track_path), psources);
+                        int track_id = DatabaseTrackInfo.GetTrackIdForUri (new SafeUri (track_path), DbId);
                         if (track_id == 0) {
                             Log.DebugFormat ("Failed to find track {0} in DAP library to load it into playlist {1}", track_path, playlist_path);
                         } else {
diff --git a/src/Dap/Banshee.Dap.Mtp/Banshee.Dap.Mtp/MtpSource.cs b/src/Dap/Banshee.Dap.Mtp/Banshee.Dap.Mtp/MtpSource.cs
index 28a6611..74591ef 100644
--- a/src/Dap/Banshee.Dap.Mtp/Banshee.Dap.Mtp/MtpSource.cs
+++ b/src/Dap/Banshee.Dap.Mtp/Banshee.Dap.Mtp/MtpSource.cs
@@ -175,10 +175,9 @@ namespace Banshee.Dap.Mtp
                     }
                 }
 
-                int [] source_ids = new int [] { DbId };
                 foreach (Track mtp_track in files) {
                     int track_id;
-                    if ((track_id = DatabaseTrackInfo.GetTrackIdForUri (MtpTrackInfo.GetPathFromMtpTrack (mtp_track), source_ids)) > 0) {
+                    if ((track_id = DatabaseTrackInfo.GetTrackIdForUri (MtpTrackInfo.GetPathFromMtpTrack (mtp_track), DbId)) > 0) {
                         track_map[track_id] = mtp_track;
                     } else {
                         MtpTrackInfo track = new MtpTrackInfo (mtp_device, mtp_track);
diff --git a/src/Extensions/Banshee.FileSystemQueue/Banshee.FileSystemQueue/FileSystemQueueSource.cs b/src/Extensions/Banshee.FileSystemQueue/Banshee.FileSystemQueue/FileSystemQueueSource.cs
index e8abf67..719f465 100644
--- a/src/Extensions/Banshee.FileSystemQueue/Banshee.FileSystemQueue/FileSystemQueueSource.cs
+++ b/src/Extensions/Banshee.FileSystemQueue/Banshee.FileSystemQueue/FileSystemQueueSource.cs
@@ -187,7 +187,7 @@ namespace Banshee.FileSystemQueue
                 return;
             }
 
-            int id = DatabaseTrackInfo.GetTrackIdForUri (uri, new int [] { DbId });
+            int id = DatabaseTrackInfo.GetTrackIdForUri (uri, DbId);
             if (id >= 0) {
                 int index = (int)TrackCache.IndexOf ((long)id);
                 if (index >= 0) {
diff --git a/src/Extensions/Banshee.Podcasting/Banshee.Podcasting/PodcastService.cs b/src/Extensions/Banshee.Podcasting/Banshee.Podcasting/PodcastService.cs
index 3ccfe21..ce98568 100644
--- a/src/Extensions/Banshee.Podcasting/Banshee.Podcasting/PodcastService.cs
+++ b/src/Extensions/Banshee.Podcasting/Banshee.Podcasting/PodcastService.cs
@@ -129,11 +129,10 @@ namespace Banshee.Podcasting
                     ");
 
                     // Finally, move podcast items from the Music Library to the Podcast source
-                    int [] primary_source_ids = new int [] { ServiceManager.SourceManager.MusicLibrary.DbId };
                     int moved = 0;
                     foreach (FeedEnclosure enclosure in FeedEnclosure.Provider.FetchAllMatching ("LocalPath IS NOT NULL AND LocalPath != ''")) {
                         SafeUri uri = new SafeUri (enclosure.LocalPath);
-                        int track_id = DatabaseTrackInfo.GetTrackIdForUri (uri, primary_source_ids);
+                        int track_id = DatabaseTrackInfo.GetTrackIdForUri (uri, ServiceManager.SourceManager.MusicLibrary.DbId);
 
                         if (track_id > 0) {
                             PodcastTrackInfo pi = new PodcastTrackInfo (DatabaseTrackInfo.Provider.FetchSingle (track_id));



[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]