private static bool IsDefaultObject <T>(ref T component, out int hashCode) where T : struct, ISharedComponentData { int typeIndex = TypeManager.GetTypeIndex <T>(); var layout = TypeManager.GetComponentType(typeIndex).FastEqualityLayout; var defaultValue = default(T); hashCode = FastEquality.GetHashCode(ref component, layout); return(FastEquality.Equals(ref defaultValue, ref component, layout)); }
public static int GetHashCode(void *val, int typeIndex) { #if !UNITY_CSHARP_TINY var typeInfo = TypeManager.GetTypeInfo(typeIndex).FastEqualityTypeInfo; return(FastEquality.GetHashCode(val, typeInfo)); #else return(StaticTypeRegistry.StaticTypeRegistry.GetHashCode(val, typeIndex & ClearFlagsMask)); #endif }
public static int GetHashCode <T>(ref T val) where T : struct { #if !UNITY_CSHARP_TINY var typeInfo = TypeManager.GetTypeInfo <T>().FastEqualityTypeInfo; return(FastEquality.GetHashCode(ref val, typeInfo)); #else return(EqualityHelper <T> .Hash(val)); #endif }
private static unsafe int GetHashCodeFast(object target, FastEquality.TypeInfo typeInfo) { ulong handle; var ptr = PinGCObjectAndGetAddress(target, out handle); var hashCode = FastEquality.GetHashCode(ptr, typeInfo); UnsafeUtility.ReleaseGCObject(handle); return(hashCode); }
unsafe static int GetHashCodeFast(object target, FastEquality.Layout[] fastLayout) { ulong handle; void *ptr = PinGCObjectAndGetAddress(target, out handle); var hashCode = FastEquality.GetHashCode(ptr, fastLayout); UnsafeUtility.ReleaseGCObject(handle); return(hashCode); }
private unsafe int FindSharedComponentIndex <T>(int typeIndex, T newData) where T : struct { var defaultVal = default(T); var typeInfo = TypeManager.GetTypeInfo(typeIndex).FastEqualityTypeInfo; if (FastEquality.Equals(ref defaultVal, ref newData, typeInfo)) { return(0); } return(FindNonDefaultSharedComponentIndex(typeIndex, FastEquality.GetHashCode(ref newData, typeInfo), UnsafeUtility.AddressOf(ref newData), typeInfo)); }
unsafe int FindSharedComponentIndex <T>(int typeIndex, T newData) where T : struct { var defaultVal = default(T); var fastLayout = TypeManager.GetComponentType(typeIndex).FastEqualityLayout; if (FastEquality.Equals(ref defaultVal, ref newData, fastLayout)) { return(0); } else { return(FindNonDefaultSharedComponentIndex(typeIndex, FastEquality.GetHashCode(ref newData, fastLayout), UnsafeUtility.AddressOf(ref newData), fastLayout)); } }
public int InsertSharedComponent <T>(T newData) where T : struct { var typeIndex = TypeManager.GetTypeIndex <T>(); var index = FindSharedComponentIndex(TypeManager.GetTypeIndex <T>(), newData); if (index == 0) { return(0); } if (index != -1) { m_SharedComponentRefCount[index]++; return(index); } var typeInfo = TypeManager.GetTypeInfo(typeIndex).FastEqualityTypeInfo; var hashcode = FastEquality.GetHashCode(ref newData, typeInfo); return(Add(typeIndex, hashcode, newData)); }
public int InsertSharedComponent <T>(T newData) where T : struct { int typeIndex = TypeManager.GetTypeIndex <T>(); int index = FindSharedComponentIndex(TypeManager.GetTypeIndex <T>(), newData); if (index == 0) { return(0); } else if (index != -1) { m_SharedComponentRefCount[index]++; return(index); } else { var fastLayout = TypeManager.GetComponentType(typeIndex).FastEqualityLayout; var hashcode = FastEquality.GetHashCode(ref newData, fastLayout); return(Add(typeIndex, hashcode, newData)); } }