Fix strange d2k loading slowness
There is a strange issue that appears* when Theater calls ISpriteFrame.Frames on the R8Reader. The R8Reader uses IEnumerable.Cast<> which behaves slower and slower, which makes map loading become 10+ times slower. The changes here simply avoid the casting. [*] This happens at least on Linux x86_64 with Mono 3.2.8. See https://bugzilla.xamarin.com/show_bug.cgi?id=19668
This commit is contained in:
@@ -8,6 +8,7 @@
|
||||
*/
|
||||
#endregion
|
||||
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Drawing;
|
||||
using System.IO;
|
||||
@@ -58,7 +59,8 @@ namespace OpenRA.FileFormats
|
||||
public class ShpReader : ISpriteSource
|
||||
{
|
||||
readonly List<ImageHeader> headers = new List<ImageHeader>();
|
||||
public IEnumerable<ISpriteFrame> Frames { get { return headers.Cast<ISpriteFrame>(); } }
|
||||
Lazy<IEnumerable<ISpriteFrame>> spriteFrames;
|
||||
public IEnumerable<ISpriteFrame> Frames { get { return spriteFrames.Value; } }
|
||||
public bool CacheWhenLoadingTileset { get { return false; } }
|
||||
public readonly Size Size;
|
||||
|
||||
@@ -93,6 +95,8 @@ namespace OpenRA.FileFormats
|
||||
|
||||
foreach (var h in headers)
|
||||
Decompress(stream, h);
|
||||
|
||||
spriteFrames = Exts.Lazy(() => headers.Cast<ISpriteFrame>());
|
||||
}
|
||||
|
||||
static byte[] ReadCompressedData(Stream stream, ImageHeader h)
|
||||
|
||||
Reference in New Issue
Block a user