From 7cf07f5765b4c2fbca28801e70014e027b0cfe77 Mon Sep 17 00:00:00 2001 From: Chris Forbes Date: Mon, 7 Mar 2011 19:53:39 +1300 Subject: [PATCH] make forcing evaluation of lazyness explicit --- OpenRA.Editor/Program.cs | 24 ++++++++++++------------ OpenRA.FileFormats/Primitives/Lazy.cs | 7 ++++++- 2 files changed, 18 insertions(+), 13 deletions(-) diff --git a/OpenRA.Editor/Program.cs b/OpenRA.Editor/Program.cs index 5dd1cfca1b..b893365e76 100644 --- a/OpenRA.Editor/Program.cs +++ b/OpenRA.Editor/Program.cs @@ -6,13 +6,13 @@ * as published by the Free Software Foundation. For more information, * see COPYING. */ -#endregion - -using System; -using System.Globalization; -using System.Windows.Forms; -using System.Linq; -using System.IO; +#endregion + +using System; +using System.Globalization; +using System.IO; +using System.Linq; +using System.Windows.Forms; using OpenRA.FileFormats; namespace OpenRA.Editor @@ -46,11 +46,11 @@ namespace OpenRA.Editor foreach (var path in ModData.FindMapsIn(MapFolderPath)) { var map = new Map(path); - // Touch the lazy bits to initialize them - var foo = map.Actors.Value.Count; - foo = map.Smudges.Value.Count; - var bar = map.MapResources.Value[0,0]; - var baz = map.MapTiles.Value[0,0]; + // Touch the lazy bits to initialize them + map.Actors.Force(); + map.Smudges.Force(); + map.MapTiles.Force(); + map.MapResources.Force(); map.Save(path); } } diff --git a/OpenRA.FileFormats/Primitives/Lazy.cs b/OpenRA.FileFormats/Primitives/Lazy.cs index b7fb3bbe40..c2735b99a2 100644 --- a/OpenRA.FileFormats/Primitives/Lazy.cs +++ b/OpenRA.FileFormats/Primitives/Lazy.cs @@ -36,7 +36,12 @@ namespace OpenRA.FileFormats p = null; return value; } - } + } + + public void Force() + { + var ignored = Value; + } } public static class Lazy