So this overall decreases the size of the PE generated, and might generate
marginal efficiency gains over the entirety of a program, but nothing to
write home to grandma about?
-R
"Kevin Yu [MSFT]" <v-****@online.microsoft.com> wrote in message
news:Nx**************@TK2MSFTNGXA01.phx.gbl...
Hi cd,
This is a typical C# language problem. IMO, there is not much performancce
gain to this single line statement than writing it out in seperate lines.
You can use the ILDASM to compare the two cases.
If I use
XmlDocument xml;
xml = new XmlDocument();
xml.LoadXml("<dom />");
The following IL code is generated in the release build using .NET 1.1 C#
compiler.
// Code size 18 (0x12)
.maxstack 2
.locals init (class [System.Xml]System.Xml.XmlDocument V_0)
IL_0000: newobj instance void
[System.Xml]System.Xml.XmlDocument::.ctor()
IL_0005: stloc.0
IL_0006: ldloc.0
IL_0007: ldstr "<dom />"
IL_000c: callvirt instance void
[System.Xml]System.Xml.XmlDocument::LoadXml(string)
IL_0011: ret
While if I use the single line of code.
XmlDocument xml;
(xml = new
XmlDocument()).LoadXml("<dom />")
This is the generated URL.
// Code size 16 (0x10)
.maxstack 2
IL_0000: newobj instance void
[System.Xml]System.Xml.XmlDocument::.ctor()
IL_0005: ldstr "<dom />"
IL_000a: callvirt instance void
[System.Xml]System.Xml.XmlDocument::LoadXml(string)
IL_000f: ret
These two lines are omitted.
IL_0005: stloc.0
IL_0006: ldloc.0
Kevin Yu
=======
"This posting is provided "AS IS" with no warranties, and confers no
rights."