فهرست منبع

优化下IAsyncStateMachineAdaptor

tanghai 4 سال پیش
والد
کامیت
5bf53326f2
1فایلهای تغییر یافته به همراه6 افزوده شده و 15 حذف شده
  1. 6 15
      Unity/Assets/Mono/ILRuntime/IAsyncStateMachineAdaptor.cs

+ 6 - 15
Unity/Assets/Mono/ILRuntime/IAsyncStateMachineAdaptor.cs

@@ -23,12 +23,11 @@ namespace ET
 
         public class IAsyncStateMachineAdaptor: IAsyncStateMachine, CrossBindingAdaptorType
         {
-            private ILTypeInstance instance;
-            private AppDomain appDomain;
+            private readonly ILTypeInstance instance;
+            private readonly AppDomain appDomain;
 
-            private IMethod mMoveNext;
-            private IMethod mSetStateMachine;
-            private readonly object[] param1 = new object[1];
+            private readonly IMethod mMoveNext;
+            private readonly IMethod mSetStateMachine;
 
             public IAsyncStateMachineAdaptor()
             {
@@ -38,27 +37,19 @@ namespace ET
             {
                 this.appDomain = appDomain;
                 this.instance = instance;
+                mMoveNext = instance.Type.GetMethod("MoveNext", 0);
+                mSetStateMachine = instance.Type.GetMethod("SetStateMachine");
             }
 
             public ILTypeInstance ILInstance => instance;
 
             public void MoveNext()
             {
-                if (this.mMoveNext == null)
-                {
-                    mMoveNext = instance.Type.GetMethod("MoveNext", 0);
-                }
-
                 this.appDomain.Invoke(mMoveNext, instance, null);
             }
 
             public void SetStateMachine(IAsyncStateMachine stateMachine)
             {
-                if (this.mSetStateMachine == null)
-                {
-                    mSetStateMachine = instance.Type.GetMethod("SetStateMachine");
-                }
-
                 this.appDomain.Invoke(mSetStateMachine, instance, stateMachine);
             }