dispose the memory stream and avoid the binary reader

This commit is contained in:
Matthias Mailänder
2015-06-24 07:15:59 +02:00
parent 3bbb5e1f7e
commit e93faeaa04

View File

@@ -65,16 +65,16 @@ namespace OpenRA.FileSystem
if (name.Length % 4 != 0)
name = name.PadRight(name.Length + (4 - name.Length % 4), '\0');
var ms = new MemoryStream(Encoding.ASCII.GetBytes(name));
var reader = new BinaryReader(ms);
using (var ms = new MemoryStream(Encoding.ASCII.GetBytes(name)))
{
var len = name.Length >> 2;
uint result = 0;
var len = name.Length >> 2;
uint result = 0;
while (len-- != 0)
result = ((result << 1) | (result >> 31)) + ms.ReadUInt32();
while (len-- != 0)
result = ((result << 1) | (result >> 31)) + reader.ReadUInt32();
return result;
return result;
}
}
case PackageHashType.CRC32: