clean up some messy GC behavior & needlessly longwinded code. slight perf cost on map save.

This commit is contained in:
Chris Forbes
2010-04-08 21:07:50 +12:00
committed by Paul Chote
parent ba24ffc442
commit ed08314ec0
3 changed files with 303 additions and 298 deletions

View File

@@ -22,6 +22,7 @@ using System;
using System.Collections.Generic;
using System.Reflection;
using System.Linq;
using System.IO;
namespace OpenRA
{
@@ -42,5 +43,22 @@ namespace OpenRA
{
return a.GetTypes().Select(t => t.Namespace).Distinct().Where(n => n != null);
}
public static string ReadAllText(this Stream s)
{
using (s)
using (var sr = new StreamReader(s))
return sr.ReadToEnd();
}
public static byte[] ReadAllBytes(this Stream s)
{
using (s)
{
var data = new byte[s.Length - s.Position];
s.Read(data, 0, data.Length);
return data;
}
}
}
}