Revert "Dispose of a MemoryStream in PackageEntry"

This commit is contained in:
Oliver Brakmann
2015-06-23 17:37:35 +02:00
parent 8dc0e79dc2
commit a572044497

View File

@@ -65,19 +65,14 @@ 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);
var len = name.Length >> 2;
uint result = 0;
var bytes = Encoding.ASCII.GetBytes(name);
unsafe
{
// Cast the data to an int array
fixed (byte* bd = &bytes[0])
{
var data = (uint*)bd;
var len = name.Length >> 2;
for (var i = 0; i < len; i++)
result = ((result << 1) | (result >> 31)) + data[i++];
}
}
while (len-- != 0)
result = ((result << 1) | (result >> 31)) + reader.ReadUInt32();
return result;
}