Example #1
0
        private int FindSharedComponentIndex <T>(int typeIndex, T newData) where T : struct
        {
            var defaultVal = default(T);

            if (TypeManager.Equals(ref defaultVal, ref newData))
            {
                return(0);
            }

            return(FindNonDefaultSharedComponentIndex(typeIndex, TypeManager.GetHashCode(ref newData),
                                                      UnsafeUtility.AddressOf(ref newData)));
        }
        public static unsafe bool FastEquality_CompareBoxed(object lhs, object rhs, int typeIndex)
        {
            ulong lhsHandle, rhsHandle;
            var   valueLHS = PinGCObjectAndGetAddress(lhs, out lhsHandle);
            var   valueRHS = PinGCObjectAndGetAddress(rhs, out rhsHandle);

            var res = TypeManager.Equals(valueLHS, valueRHS, typeIndex);

            UnsafeUtility.ReleaseGCObject(lhsHandle);
            UnsafeUtility.ReleaseGCObject(rhsHandle);

            return(res);
        }
Example #3
0
        public static unsafe bool FastEquality_CompareElements(void *lhs, void *rhs, int count, int typeIndex)
        {
            var typeInfo = TypeManager.GetTypeInfo(typeIndex);

            for (var i = 0; i < count; ++i)
            {
                if (!TypeManager.Equals(lhs, rhs, typeIndex))
                {
                    return(false);
                }
                lhs = (byte *)lhs + typeInfo.ElementSize;
                rhs = (byte *)rhs + typeInfo.ElementSize;
            }
            return(true);
        }
Example #4
0
        private unsafe int FindNonDefaultSharedComponentIndex(int typeIndex, int hashCode, object newData)
        {
            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)
                {
                    if (TypeManager.Equals(data, newData, typeIndex))
                        return itemIndex;
                }
            } while (m_HashLookup.TryGetNextValue(out itemIndex, ref iter));

            return -1;
        }
        public static unsafe bool FastEquality_ComparePtr(void *lhs, void *rhs, int typeIndex)
        {
            var res = TypeManager.Equals(lhs, rhs, typeIndex);

            return(res);
        }