Skip to content

Commit 414dd7f

Browse files
committed
TryGetValue for performance
1 parent 61b9837 commit 414dd7f

File tree

1 file changed

+2
-3
lines changed

1 file changed

+2
-3
lines changed

src/Neo.Compiler.CSharp/Optimizer/Strategies/Reachability.cs

+2-3
Original file line numberDiff line numberDiff line change
@@ -72,9 +72,8 @@ public static (NefFile, ContractManifest, JObject) RemoveUncoveredInstructions(N
7272
simplifiedScript.Add((byte)i.OpCode);
7373
int operandSizeLength = OperandSizePrefixTable[(int)i.OpCode];
7474
simplifiedScript = simplifiedScript.Concat(BitConverter.GetBytes(i.Operand.Length)[0..operandSizeLength]).ToList();
75-
if (jumpInstructionSourceToTargets.ContainsKey(i))
75+
if (jumpInstructionSourceToTargets.TryGetValue(i, out Instruction? dst))
7676
{
77-
Instruction dst = jumpInstructionSourceToTargets[i];
7877
int delta = (int)simplifiedInstructionsToAddress[dst]! - a;
7978
if (i.OpCode == OpCode.JMP || conditionalJump.Contains(i.OpCode) || i.OpCode == OpCode.CALL || i.OpCode == OpCode.ENDTRY)
8079
simplifiedScript.Add(BitConverter.GetBytes(delta)[0]);
@@ -160,7 +159,7 @@ public static Dictionary<int, bool>
160159
{
161160
Script script = nef.Script;
162161
Dictionary<int, bool> coveredMap = new();
163-
foreach ((int addr, Instruction inst) in script.EnumerateInstructions())
162+
foreach ((int addr, Instruction _) in script.EnumerateInstructions())
164163
coveredMap.Add(addr, false);
165164

166165
Dictionary<int, string> publicMethodStartingAddressToName = new();

0 commit comments

Comments
 (0)