Skip to content

Commit

Permalink
remove unnecessary clones
Browse files Browse the repository at this point in the history
  • Loading branch information
Hecate2 committed Sep 9, 2024
1 parent 326db42 commit 806b1d1
Showing 1 changed file with 6 additions and 5 deletions.
11 changes: 6 additions & 5 deletions src/Neo.Compiler.CSharp/Optimizer/Strategies/Optimizer.cs
Original file line number Diff line number Diff line change
Expand Up @@ -64,11 +64,12 @@ public static (NefFile, ContractManifest, JObject?) Optimize(NefFile nef, Contra
if (!optimizationType.HasFlag(CompilationOptions.OptimizationType.Experimental))
return (nef, manifest, debugInfo); // do nothing
// TODO in the future: optimize by StrategyAttribute in a loop
(nef, manifest, debugInfo) = Reachability.RemoveUnnecessaryJumps(nef, manifest, debugInfo!.Clone() as JObject);
(nef, manifest, debugInfo) = Reachability.ReplaceJumpWithRet(nef, manifest, debugInfo!.Clone() as JObject);
(nef, manifest, debugInfo) = Reachability.RemoveUncoveredInstructions(nef, manifest, debugInfo!.Clone() as JObject);
(nef, manifest, debugInfo) = Reachability.RemoveUnnecessaryJumps(nef, manifest, debugInfo!.Clone() as JObject);
(nef, manifest, debugInfo) = Reachability.ReplaceJumpWithRet(nef, manifest, debugInfo!.Clone() as JObject);
debugInfo = debugInfo?.Clone() as JObject; // do not pollute the input when optimization fails
(nef, manifest, debugInfo) = Reachability.RemoveUnnecessaryJumps(nef, manifest, debugInfo);
(nef, manifest, debugInfo) = Reachability.ReplaceJumpWithRet(nef, manifest, debugInfo);
(nef, manifest, debugInfo) = Reachability.RemoveUncoveredInstructions(nef, manifest, debugInfo);
(nef, manifest, debugInfo) = Reachability.RemoveUnnecessaryJumps(nef, manifest, debugInfo);
(nef, manifest, debugInfo) = Reachability.ReplaceJumpWithRet(nef, manifest, debugInfo);
return (nef, manifest, debugInfo);
}
}
Expand Down

0 comments on commit 806b1d1

Please sign in to comment.