Use spans to improve performance in StreamExts.
Also avoid ReadBytes calls that allocate a buffer by either updating the stream position (if not interested in the bytes), by reusing an input buffer (if interested in the bytes), or using a stackalloc buffer to avoid the allocation (for small reads).
This commit is contained in:
@@ -117,10 +117,7 @@ namespace OpenRA.FileSystem
|
||||
|
||||
void Commit()
|
||||
{
|
||||
var pos = pkgStream.Position;
|
||||
pkgStream.Position = 0;
|
||||
File.WriteAllBytes(Name, pkgStream.ReadBytes((int)pkgStream.Length));
|
||||
pkgStream.Position = pos;
|
||||
File.WriteAllBytes(Name, pkgStream.ToArray());
|
||||
}
|
||||
|
||||
public void Update(string filename, byte[] contents)
|
||||
|
||||
Reference in New Issue
Block a user