Hy JB,

While I was benchmarking the performance of my code flow obfuscation
using some important assemblies, I found that the method
MethodBody.Optimize() is not quite optimized.
In fact, it was taking more than 6 seconds for optimizing all methods
of a 3 MB assembly. This is because every time a branch was optimized,
it had to recompute all instruction offsets from the beginning :

void OptimizeBranches ()
{
        ComputeOffsets ();
        foreach (Instruction instr in m_instructions) {
                if (instr.OpCode.OperandType != OperandType.InlineBrTarget)
                        continue;

                        if (OptimizeBranch (instr))
                        ComputeOffsets (); // <-- This should be changed to not 
recompute
all instructions
        }
}

By changing a little bit the ComputeOffsets method, I was able to
reduce it's processeing time to less than 1.5 secs. See uploaded file
MethodBody.Optimize.patch
--~--~---------~--~----~------------~-------~--~----~
--
mono-cecil
-~----------~----~----~----~------~----~------~--~---

Reply via email to