@@ -10,6 +10,7 @@ namespace Exiled.Events.Patches.Events.Scp079
10
10
using System . Collections . Generic ;
11
11
using System . Reflection . Emit ;
12
12
13
+ using Exiled . API . Features . Pools ;
13
14
using Exiled . Events . Attributes ;
14
15
using Exiled . Events . EventArgs . Scp079 ;
15
16
using Exiled . Events . Handlers ;
@@ -31,11 +32,11 @@ internal class Recontaining
31
32
private static IEnumerable < CodeInstruction > Transpiler ( IEnumerable < CodeInstruction > instructions , ILGenerator generator )
32
33
{
33
34
int index = 0 ;
34
- List < CodeInstruction > newInstructions = new ( instructions ) ;
35
+ List < CodeInstruction > newInstructions = ListPool < CodeInstruction > . Pool . Get ( instructions ) ;
35
36
36
37
LocalBuilder ev = generator . DeclareLocal ( typeof ( RecontainingEventArgs ) ) ;
37
38
38
- Label proceed = generator . DefineLabel ( ) ;
39
+ Label returnLabel = generator . DefineLabel ( ) ;
39
40
40
41
newInstructions . InsertRange ( index , new CodeInstruction [ ]
41
42
{
@@ -52,14 +53,17 @@ private static IEnumerable<CodeInstruction> Transpiler(IEnumerable<CodeInstructi
52
53
// if (!ev.IsAllowed) return;
53
54
new ( OpCodes . Ldarg_S , ev . LocalIndex ) ,
54
55
new ( OpCodes . Callvirt , Method ( typeof ( RecontainingEventArgs ) , nameof ( RecontainingEventArgs . IsAllowed ) ) ) ,
55
- new ( OpCodes . Brtrue_S , proceed ) ,
56
+ new ( OpCodes . Brtrue_S , returnLabel ) ,
56
57
57
58
new ( OpCodes . Ret ) ,
58
-
59
- new CodeInstruction ( OpCodes . Nop ) . WithLabels ( proceed ) ,
60
59
} ) ;
61
60
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 ) ;
63
67
}
64
68
}
65
69
}
0 commit comments