Open qn9663 opened 3 years ago
自己写了一个List,主要是自带的list clear和remove时候产生gc
热更层的源码能麻烦提供一下吗?
热更:
public class SortComparer : IComparer<AchievementInstance> { public SortComparer() { } public int Compare(AchievementInstance a, AchievementInstance b) { return a.MissionId.CompareTo(b.MissionId); } }
FastList
底层:
public class FastList
}
public void Sort(IComparer<T> comparer) { if (mCount > 0) { Array.Sort<T>(mItems, 0, mCount, comparer); } }
是不是我的用法问题? 我如果是比较的话,我测试过确实是判断不到这个接口类型.
appdomain.RegisterCrossBindingAdaptor(new IComparerAdapter());
`using System; using ILRuntime.CLR.Method; using ILRuntime.Runtime.Enviorment; using ILRuntime.Runtime.Intepreter;
namespace ProjectAdapter { public class IComparerAdapter : CrossBindingAdaptor { static CrossBindingFunctionInfo<ILRuntime.Runtime.Intepreter.ILTypeInstance, ILRuntime.Runtime.Intepreter.ILTypeInstance,int> mExampleMethod_0 = new CrossBindingFunctionInfo<ILRuntime.Runtime.Intepreter.ILTypeInstance, ILRuntime.Runtime.Intepreter.ILTypeInstance,int>("Compare"); public override Type BaseCLRType { get { return typeof(System.Collections.Generic.IComparer);
}
}
}
`
//热更新无法识别,需要修改如下才行.
public IMethod GetMethod(string name, List<IType> param, IType[] genericArguments, IType returnType = null, bool declaredOnly = false) { if (methods == null) InitializeMethods(); List<ILMethod> lst; IMethod genericMethod = null; if (methods.TryGetValue(name, out lst)) { for (var idx = 0; idx < lst.Count; idx++) { var i = lst[idx]; int pCnt = param != null ? param.Count : 0; if (i.ParameterCount == pCnt) { bool match = true; if (genericArguments != null && i.GenericParameterCount == genericArguments.Length && genericMethod == null) { genericMethod = CheckGenericParams(i, param, ref match); } else { match = CheckGenericArguments(i, genericArguments); if (!match) continue; for (int j = 0; j < pCnt; j++) { **if (i.Parameters[j].TypeForCLR == typeof(ILTypeInstance))//修改 { if (param[j].TypeForCLR != i.Parameters[j].TypeForCLR) { match = false; break; } }** else { if (param[j] != i.Parameters[j]) { match = false; break; } } } if (match) { match = returnType == null || i.ReturnType == returnType; } if (match) return i; } } } } if (genericArguments != null && genericMethod != null) { var m = genericMethod.MakeGenericMethod(genericArguments); lst.Add((ILMethod)m); return m; } if (declaredOnly) return null; else { if (BaseType != null) return BaseType.GetMethod(name, param, genericArguments, returnType, false); else return null; } }