Skip to content

Commit e58bac7

Browse files
committed
Use manual xml parsing for fast start-up
1 parent 2fa5b9d commit e58bac7

File tree

1 file changed

+10
-10
lines changed

1 file changed

+10
-10
lines changed

core/IncrementalCompiler/Settings.cs

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
1-
using System.IO;
1+
using System;
2+
using System.IO;
23
using System.Reflection;
3-
using System.Xml.Serialization;
4+
using System.Xml.Linq;
45

56
namespace IncrementalCompiler
67
{
@@ -29,14 +30,13 @@ public static Settings Load()
2930

3031
public static Settings Load(Stream stream)
3132
{
32-
var deserializer = new XmlSerializer(typeof(Settings));
33-
return (Settings)deserializer.Deserialize(stream);
34-
}
35-
36-
public static void Save(Stream stream, Settings settings)
37-
{
38-
var serializer = new XmlSerializer(typeof(Settings));
39-
serializer.Serialize(stream, settings);
33+
// To reduce start-up time, do manual parsing instead of using XmlSerializer
34+
var xdoc = XDocument.Load(stream).Element("Settings");
35+
return new Settings
36+
{
37+
DebugSymbolFile = (DebugSymbolFileType)Enum.Parse(typeof(DebugSymbolFileType), xdoc.Element("DebugSymbolFile").Value),
38+
PrebuiltOutputReuse = (PrebuiltOutputReuseType)Enum.Parse(typeof(PrebuiltOutputReuseType), xdoc.Element("PrebuiltOutputReuse").Value),
39+
};
4040
}
4141
}
4242
}

0 commit comments

Comments
 (0)