public void GetHashCode_OnlyHashesLengthBytes() { var array = new ResizableArray64Byte <int>(); var hashPre = array.GetHashCode(); ++array.Length; var hashPost = array.GetHashCode(); Assert.AreNotEqual(hashPre, hashPost); }
unsafe EntityQuery ResolveEntityQuery(int *delegateTypeIndices, int delegateTypeCount) { SanitizeTypes(delegateTypeIndices, ref delegateTypeCount); var hash = (uint)m_Any.GetHashCode() * 0xEA928FF9 ^ (uint)m_None.GetHashCode() * 0x4B772F25 ^ (uint)m_All.GetHashCode() * 0xBAEE8991 ^ (uint)m_AnyWritableBitField.GetHashCode() * 0x8F8BF1C7 ^ (uint)m_AllWritableBitField.GetHashCode() * 0xB6D633F7 ^ (uint)m_Options.GetHashCode() * 0xE0B7379B ^ math.hash(delegateTypeIndices, sizeof(int) * delegateTypeCount); var cache = m_System.GetOrCreateEntityQueryCache(); var found = cache.FindQueryInCache(hash); if (found < 0) { // base query from builder spec, but reserve some extra room for the types detected from the delegate var eaq = ToEntityQueryDesc(delegateTypeCount); // now fill out the extra types for (var i = 0; i < delegateTypeCount; ++i) { eaq.All[i + m_All.Length] = ComponentType.FromTypeIndex(delegateTypeIndices[i]); } var query = m_System.GetEntityQuery(eaq); #if ENABLE_UNITY_COLLECTIONS_CHECKS found = cache.CreateCachedQuery(hash, query, ref this, delegateTypeIndices, delegateTypeCount); #else found = cache.CreateCachedQuery(hash, query); #endif } #if ENABLE_UNITY_COLLECTIONS_CHECKS else { cache.ValidateMatchesCache(found, ref this, delegateTypeIndices, delegateTypeCount); // TODO: also validate that m_Query spec matches m_Any/All/None and delegateTypeIndices } #endif return(cache.GetCachedQuery(found)); }
unsafe ComponentGroup ResolveComponentGroup(int *delegateTypeIndices, int delegateTypeCount) { var hash = (uint)m_Any.GetHashCode() * 0xEA928FF9 ^ (uint)m_None.GetHashCode() * 0x4B772F25 ^ (uint)m_All.GetHashCode() * 0xBAEE8991 ^ math.hash(delegateTypeIndices, sizeof(int) * delegateTypeCount); var cache = m_System.GetOrCreateEntityQueryCache(); var found = cache.FindQueryInCache(hash); if (found < 0) { // base query from builder spec, but reserve some extra room for the types detected from the delegate var eaq = ToEntityArchetypeQuery(delegateTypeCount); // now fill out the extra types for (var i = 0; i < delegateTypeCount; ++i) { eaq.All[i + m_All.Length] = ComponentType.FromTypeIndex(delegateTypeIndices[i]); } var group = m_System.GetComponentGroup(eaq); #if ENABLE_UNITY_COLLECTIONS_CHECKS found = cache.CreateCachedQuery(hash, group, ref this, delegateTypeIndices, delegateTypeCount); #else found = cache.CreateCachedQuery(hash, group); #endif } #if ENABLE_UNITY_COLLECTIONS_CHECKS else { cache.ValidateMatchesCache(found, ref this, delegateTypeIndices, delegateTypeCount); // TODO: also validate that m_Group spec matches m_Any/All/None and delegateTypeIndices } #endif return(cache.GetCachedQuery(found)); }