private unsafe int FindNonDefaultSharedComponentIndex(int typeIndex, int hashCode, void *newData, FastEquality.TypeInfo typeInfo) { int itemIndex; NativeMultiHashMapIterator <int> iter; if (!m_HashLookup.TryGetFirstValue(hashCode, out itemIndex, out iter)) { return(-1); } do { var data = m_SharedComponentData[itemIndex]; if (data != null && m_SharedComponentType[itemIndex] == typeIndex) { ulong handle; var value = PinGCObjectAndGetAddress(data, out handle); var res = FastEquality.Equals(newData, value, typeInfo); UnsafeUtility.ReleaseGCObject(handle); if (res) { return(itemIndex); } } } while (m_HashLookup.TryGetNextValue(out itemIndex, ref iter)); return(-1); }
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 bool Equals(void *left, void *right, int typeIndex) { #if !UNITY_CSHARP_TINY var typeInfo = TypeManager.GetTypeInfo(typeIndex).FastEqualityTypeInfo; return(FastEquality.Equals(left, right, typeInfo)); #else return(StaticTypeRegistry.StaticTypeRegistry.Equals(left, right, typeIndex & ClearFlagsMask)); #endif }
public static bool Equals <T>(ref T left, ref T right) where T : struct { #if !UNITY_CSHARP_TINY var typeInfo = TypeManager.GetTypeInfo <T>().FastEqualityTypeInfo; return(FastEquality.Equals(ref left, ref right, typeInfo)); #else return(EqualityHelper <T> .Equals(left, right)); #endif }
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)); } }