SLua最適化初期化速度


Luaに多くのクラスをエクスポートし、直接ゲームが開いたときにSLuaを初期化するのに3-4秒かかりました.
プロジェクトのSLuaを2つ最適化しました.
1.エクスポートされたクラスには、Luaで使用されるPublic関数、変数がなく、すべて[SLua.DoNotToLua]属性が追加されます.
2、LuaSvrには、次のようなコードがあります.
static void bindAll(IntPtr l)
{
	// add RELEASE macro to switch on below codes
#if RELEASE && (UNITY_IOS || UNITY_ANDROID)
    BindUnity.Bind(l);
    BindUnityUI.Bind(l); // delete this line if not found
    BindDll.Bind(l); // delete this line if not found
    BindCustom.Bind(l); 
#else
    Assembly[] ams = AppDomain.CurrentDomain.GetAssemblies();

	List bindlist = new List();
	foreach(Assembly a in ams) 
	{
		Type[] ts=a.GetExportedTypes();
		foreach (Type t in ts)
		{
			if (t.GetCustomAttributes(typeof(LuaBinderAttribute),false).Length > 0)
			{
				bindlist.Add(t);
			}
		}
	}

	bindlist.Sort( new System.Comparison((Type a,Type b) =>
	{
		LuaBinderAttribute la = (LuaBinderAttribute)a.GetCustomAttributes(typeof(LuaBinderAttribute),false)[0];
		LuaBinderAttribute lb = (LuaBinderAttribute)b.GetCustomAttributes(typeof(LuaBinderAttribute),false)[0];

		return la.order.CompareTo(lb.order);
	})
	);

	foreach (Type t in bindlist)
	{
		t.GetMethod("Bind").Invoke(null, new object[] { l });
	}
#endif
}

したがって、RELEASEマクロ定義を追加できます.
1日やった後、初期化速度が60 ms加速しました!