Author: alanmc
Date: 2008-02-03 16:30:01 -0500 (Sun, 03 Feb 2008)
New Revision: 94721
Modified:
trunk/bitsharp/src/MonoTorrent/MonoTorrent.Client/FileStreamBuffer.cs
trunk/bitsharp/src/MonoTorrent/MonoTorrent.Client/Managers/ChokeUnchokeManager.cs
trunk/bitsharp/src/MonoTorrent/MonoTorrent.Client/Managers/DiskManager.cs
trunk/bitsharp/src/MonoTorrent/MonoTorrent.Client/Managers/FileManager.cs
trunk/bitsharp/src/MonoTorrent/MonoTorrent.Client/PiecePicking/StandardPicker.cs
trunk/bitsharp/src/MonoTorrent/MonoTorrent.Common/MonoTorrentCollectionBase.cs
Log:
Cosmetic
Modified: trunk/bitsharp/src/MonoTorrent/MonoTorrent.Client/FileStreamBuffer.cs
===================================================================
--- trunk/bitsharp/src/MonoTorrent/MonoTorrent.Client/FileStreamBuffer.cs
2008-02-03 21:14:00 UTC (rev 94720)
+++ trunk/bitsharp/src/MonoTorrent/MonoTorrent.Client/FileStreamBuffer.cs
2008-02-03 21:30:01 UTC (rev 94721)
@@ -73,8 +73,7 @@
public void Dispose()
{
- foreach (Stream s in list)
- s.Dispose();
+ list.ForEach(delegate (TorrentFileStream s) { s.Dispose(); });
}
#endregion
@@ -91,9 +90,9 @@
private void CloseAndRemove(TorrentFileStream s)
{
Console.WriteLine("Closing and removing: {0}", s.File.Path);
- int index = list.FindIndex(delegate(TorrentFileStream stream) {
- return stream == s;
- });
+ int index = list.FindIndex(delegate(TorrentFileStream stream) {
return stream == s; });
+ if (index == -1)
+ return;
list[index].Dispose();
list.RemoveAt(index);
Modified:
trunk/bitsharp/src/MonoTorrent/MonoTorrent.Client/Managers/ChokeUnchokeManager.cs
===================================================================
---
trunk/bitsharp/src/MonoTorrent/MonoTorrent.Client/Managers/ChokeUnchokeManager.cs
2008-02-03 21:14:00 UTC (rev 94720)
+++
trunk/bitsharp/src/MonoTorrent/MonoTorrent.Client/Managers/ChokeUnchokeManager.cs
2008-02-03 21:30:01 UTC (rev 94721)
@@ -511,8 +511,7 @@
private void UnchokePeerList(List<PeerIdInternal> PeerList)
{
//Unchoke all the peers in the supplied list
- foreach (PeerIdInternal PeerToUnchoke in PeerList)
- Unchoke(PeerToUnchoke);
+ PeerList.ForEach(delegate(PeerIdInternal d) { Unchoke(d); });
}
#endregion
Modified:
trunk/bitsharp/src/MonoTorrent/MonoTorrent.Client/Managers/DiskManager.cs
===================================================================
--- trunk/bitsharp/src/MonoTorrent/MonoTorrent.Client/Managers/DiskManager.cs
2008-02-03 21:14:00 UTC (rev 94720)
+++ trunk/bitsharp/src/MonoTorrent/MonoTorrent.Client/Managers/DiskManager.cs
2008-02-03 21:30:01 UTC (rev 94721)
@@ -101,8 +101,7 @@
internal void CloseFileStreams(TorrentManager manager)
{
- foreach (TorrentFile file in manager.Torrent.Files)
- streamsBuffer.CloseStream(file);
+ Array.ForEach<TorrentFile>(manager.Torrent.Files,
delegate(TorrentFile f) { streamsBuffer.CloseStream(f); });
}
Modified:
trunk/bitsharp/src/MonoTorrent/MonoTorrent.Client/Managers/FileManager.cs
===================================================================
--- trunk/bitsharp/src/MonoTorrent/MonoTorrent.Client/Managers/FileManager.cs
2008-02-03 21:14:00 UTC (rev 94720)
+++ trunk/bitsharp/src/MonoTorrent/MonoTorrent.Client/Managers/FileManager.cs
2008-02-03 21:30:01 UTC (rev 94721)
@@ -141,11 +141,9 @@
internal bool CheckFilesExist()
{
- foreach (TorrentFile file in files)
- if(File.Exists(GenerateFilePath(file, BaseDirectory,
savePath)))
- return true;
-
- return false;
+ return Array.Exists<TorrentFile>(files, delegate(TorrentFile f) {
+ return File.Exists(GenerateFilePath(f, BaseDirectory,
savePath));
+ });
}
#endregion
Modified:
trunk/bitsharp/src/MonoTorrent/MonoTorrent.Client/PiecePicking/StandardPicker.cs
===================================================================
---
trunk/bitsharp/src/MonoTorrent/MonoTorrent.Client/PiecePicking/StandardPicker.cs
2008-02-03 21:14:00 UTC (rev 94720)
+++
trunk/bitsharp/src/MonoTorrent/MonoTorrent.Client/PiecePicking/StandardPicker.cs
2008-02-03 21:30:01 UTC (rev 94721)
@@ -126,9 +126,8 @@
if (this.myBitfield[index])
return true;
- foreach (Piece p in this.requests)
- if (p.Index == index)
- return true;
+ if (requests.Exists(delegate (Piece p) { return p.Index == index;
}))
+ return true;
lock (this.unhashedPieces)
return this.unhashedPieces[index];
Modified:
trunk/bitsharp/src/MonoTorrent/MonoTorrent.Common/MonoTorrentCollectionBase.cs
===================================================================
---
trunk/bitsharp/src/MonoTorrent/MonoTorrent.Common/MonoTorrentCollectionBase.cs
2008-02-03 21:14:00 UTC (rev 94720)
+++
trunk/bitsharp/src/MonoTorrent/MonoTorrent.Common/MonoTorrentCollectionBase.cs
2008-02-03 21:30:01 UTC (rev 94721)
@@ -173,5 +173,10 @@
{
return list.Find(match);
}
+
+ internal bool Exists(Predicate<T> match)
+ {
+ return list.Exists(match);
+ }
}
}
_______________________________________________
Mono-patches maillist - [email protected]
http://lists.ximian.com/mailman/listinfo/mono-patches