Optimize ComputeHash by removing Concat() and ToArray() calls
This commit is contained in:
@@ -431,13 +431,20 @@ namespace OpenRA
|
|||||||
string ComputeHash()
|
string ComputeHash()
|
||||||
{
|
{
|
||||||
// UID is calculated by taking an SHA1 of the yaml and binary data
|
// UID is calculated by taking an SHA1 of the yaml and binary data
|
||||||
// Read the relevant data into a buffer
|
|
||||||
var data = Container.GetContent("map.yaml").ReadAllBytes()
|
using (var ms = new MemoryStream())
|
||||||
.Concat(Container.GetContent("map.bin").ReadAllBytes()).ToArray();
|
{
|
||||||
|
// Read the relevant data into the buffer
|
||||||
|
using (var s = Container.GetContent("map.yaml"))
|
||||||
|
s.CopyTo(ms);
|
||||||
|
using (var s = Container.GetContent("map.bin"))
|
||||||
|
s.CopyTo(ms);
|
||||||
|
|
||||||
// Take the SHA1
|
// Take the SHA1
|
||||||
|
ms.Seek(0, SeekOrigin.Begin);
|
||||||
using (var csp = SHA1.Create())
|
using (var csp = SHA1.Create())
|
||||||
return new string(csp.ComputeHash(data).SelectMany(a => a.ToString("x2")).ToArray());
|
return new string(csp.ComputeHash(ms).SelectMany(a => a.ToString("x2")).ToArray());
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public void MakeDefaultPlayers()
|
public void MakeDefaultPlayers()
|
||||||
|
|||||||
Reference in New Issue
Block a user