Skip to content

Commit

Permalink
Core: Optimize ISILControlFlowGraph.Build time
Browse files Browse the repository at this point in the history
  • Loading branch information
SamboyCoding committed Aug 12, 2024
1 parent 671f78c commit 5c0a0c0
Showing 1 changed file with 11 additions and 4 deletions.
15 changes: 11 additions & 4 deletions Cpp2IL.Core/Graphs/ISILControlFlowGraph.cs
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,7 @@ public void Build(List<InstructionSetIndependentInstruction> instructions)
AddNode(newNodeFromJmp);
if (TryGetTargetJumpInstructionIndex(instructions[i], out uint jumpTargetIndex))
{
var result = instructions.Any(instruction => instruction.InstructionIndex == jumpTargetIndex);
// var result = instructions.Any(instruction => instruction.InstructionIndex == jumpTargetIndex);
currentBlock.Dirty = true;
} else
{
Expand Down Expand Up @@ -214,13 +214,20 @@ private void FixBlock(Block block, bool removeJmp = false)
{
if (instruction == null)
return null;
foreach (var block in blockSet)

for (var i = 0; i < blockSet.Count; i++)
{
if (block.isilInstructions.Any(instr => instr == instruction))
var block = blockSet[i];
for (var j = 0; j < block.isilInstructions.Count; j++)
{
return block;
var instr = block.isilInstructions[j];
if (instr == instruction)
{
return block;
}
}
}

return null;
}

Expand Down

0 comments on commit 5c0a0c0

Please sign in to comment.