Skip to content

Commit 18db618

Browse files
committed
consistency
1 parent f3b17ea commit 18db618

File tree

1 file changed

+10
-6
lines changed

1 file changed

+10
-6
lines changed

EXILED/Exiled.Events/Patches/Events/Scp079/Recontaining.cs

Lines changed: 10 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@ namespace Exiled.Events.Patches.Events.Scp079
1010
using System.Collections.Generic;
1111
using System.Reflection.Emit;
1212

13+
using Exiled.API.Features.Pools;
1314
using Exiled.Events.Attributes;
1415
using Exiled.Events.EventArgs.Scp079;
1516
using Exiled.Events.Handlers;
@@ -31,11 +32,11 @@ internal class Recontaining
3132
private static IEnumerable<CodeInstruction> Transpiler(IEnumerable<CodeInstruction> instructions, ILGenerator generator)
3233
{
3334
int index = 0;
34-
List<CodeInstruction> newInstructions = new(instructions);
35+
List<CodeInstruction> newInstructions = ListPool<CodeInstruction>.Pool.Get(instructions);
3536

3637
LocalBuilder ev = generator.DeclareLocal(typeof(RecontainingEventArgs));
3738

38-
Label proceed = generator.DefineLabel();
39+
Label returnLabel = generator.DefineLabel();
3940

4041
newInstructions.InsertRange(index, new CodeInstruction[]
4142
{
@@ -52,14 +53,17 @@ private static IEnumerable<CodeInstruction> Transpiler(IEnumerable<CodeInstructi
5253
// if (!ev.IsAllowed) return;
5354
new(OpCodes.Ldarg_S, ev.LocalIndex),
5455
new(OpCodes.Callvirt, Method(typeof(RecontainingEventArgs), nameof(RecontainingEventArgs.IsAllowed))),
55-
new(OpCodes.Brtrue_S, proceed),
56+
new(OpCodes.Brtrue_S, returnLabel),
5657

5758
new(OpCodes.Ret),
58-
59-
new CodeInstruction(OpCodes.Nop).WithLabels(proceed),
6059
});
6160

62-
return newInstructions;
61+
newInstructions[newInstructions.Count - 1].WithLabels(returnLabel);
62+
63+
for (int z = 0; z < newInstructions.Count; z++)
64+
yield return newInstructions[z];
65+
66+
ListPool<CodeInstruction>.Pool.Return(newInstructions);
6367
}
6468
}
6569
}

0 commit comments

Comments
 (0)