コード例 #1
0
ファイル: McgModule.cs プロジェクト: tmds/corert
        /// <summary>
        /// Given a GUID, retrieve the corresponding RuntimeTypeHandle
        /// @TODO: we should switch everything to RuntimeTypeHandle instead of relying on Guid
        /// </summary>
        unsafe internal RuntimeTypeHandle GetTypeFromGuid(ref Guid guid)
        {
            if (m_interfaceData != null)
            {
                if (m_guidMap == null)
                {
                    int size = m_interfaceData.Length;

                    FixedHashTable map = new FixedHashTable(size);

                    for (int i = 0; i < size; i++)
                    {
                        map.Add(m_interfaceData[i].ItfGuid.GetHashCode(), i);
                    }

                    Interlocked.CompareExchange(ref m_guidMap, map, null);
                }

                int hash = guid.GetHashCode();

                // Search hash table
                for (int slot = m_guidMap.GetFirst(hash); slot >= 0; slot = m_guidMap.GetNext(slot))
                {
                    if (InteropExtensions.GuidEquals(ref guid, ref m_interfaceData[slot].ItfGuid))
                    {
                        return(m_interfaceData[slot].ItfType);
                    }
                }
            }

            return(default(RuntimeTypeHandle));
        }
コード例 #2
0
        /// <summary>
        /// Dictionary.TryGetValue(string)
        /// </summary>
        internal int FindString(string name)
        {
            if (m_map == null)
            {
                FixedHashTable map = new FixedHashTable(m_size);

                for (int i = 0; i < m_size; i++)
                {
                    map.Add(GetStringHash(i), i);
                }

                m_map = map;
            }

            int hash = StringPool.StableStringHash(name);

            // Search hash table
            for (int slot = m_map.GetFirst(hash); slot >= 0; slot = m_map.GetNext(slot))
            {
                int index = m_map.GetIndex(slot);

                if (IsStringEqual(name, index))
                {
                    return(index);
                }
            }

            return(-1);
        }
コード例 #3
0
        /// <summary>
        /// Dictionary.TryGetValue(string)
        /// </summary>
        internal int FindString(string name)
        {
            if (m_map == null)
            {
                FixedHashTable map = new FixedHashTable(m_size);

                for (int i = 0; i < m_size; i++)
                {
                    map.Add(GetStringHash(i), i);
                }

                m_map = map;
            }

            int hash = StringPool.StableStringHash(name);

            // Search hash table
            for (int slot = m_map.GetFirst(hash); slot >= 0; slot = m_map.GetNext(slot))
            {
                int index = m_map.GetIndex(slot);

                if (IsStringEqual(name, index))
                {
                    return index;
                }
            }

            return -1;
        }