clean up some messy GC behavior & needlessly longwinded code. slight perf cost on map save.
This commit is contained in:
@@ -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;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user