rendered paste bodyIndex: Mono.Cecil.Cil/CodeReader.cs
===================================================================
--- Mono.Cecil.Cil/CodeReader.cs (revision 97762)
+++ Mono.Cecil.Cil/CodeReader.cs (working copy)
@@ -40,6 +40,7 @@
ReflectionReader m_reflectReader;
MetadataRoot m_root;
+ IDictionary instrs;
public CodeReader (ReflectionReader reflectReader)
{
@@ -54,13 +55,15 @@
BinaryReader br = m_reflectReader.Module.ImageReader.MetadataReader.GetDataReader (meth.RVA);
// lets read the method
- IDictionary instrs;
+ if (instrs == null)
+ instrs = new Hashtable ();
+
int flags = br.ReadByte ();
switch (flags & 0x3) {
case (int) MethodHeader.TinyFormat :
methBody.CodeSize = flags >> 2;
methBody.MaxStack = 8;
- ReadCilBody (methBody, br, out instrs);
+ ReadCilBody (methBody, br, ref instrs);
break;
case (int) MethodHeader.FatFormat :
br.BaseStream.Position--;
@@ -71,7 +74,7 @@
methBody.LocalVarToken = br.ReadInt32 ();
body.InitLocals = (fatflags & (int) MethodHeader.InitLocals) != 0;
VisitVariableDefinitionCollection (methBody.Variables);
- ReadCilBody (methBody, br, out instrs);
+ ReadCilBody (methBody, br, ref instrs);
if ((fatflags & (int) MethodHeader.MoreSects) != 0)
ReadSection (methBody, br, instrs);
break;
@@ -102,12 +105,12 @@
return body.Variables [index];
}
- void ReadCilBody (MethodBody body, BinaryReader br, out IDictionary instructions)
+ void ReadCilBody (MethodBody body, BinaryReader br, ref IDictionary instructions)
{
long start = br.BaseStream.Position;
Instruction last = null;
InstructionCollection code = body.Instructions;
- instructions = new Hashtable ();
+ instructions.Clear ();
GenericContext context = new GenericContext (body.Method);
while (br.BaseStream.Position < start + body.CodeSize) {