Exemple #1
0
        /// <summary>
        /// Collects the dead keys. This frees up memory but invalidates pending iterators.
        /// It's called automatically internally when the semantics of Lua tables allow, but can be forced
        /// externally if it's known that no iterators are pending.
        /// </summary>
        public void CollectDeadKeys()
        {
            for (LinkedListNode <TablePair> node = m_Values.First; node != null; node = node.Next)
            {
                if (node.Value.Value.IsNil())
                {
                    if (node.Value.Key.Type == DataType.Number)
                    {
                        int idx = GetIntegralKey(node.Value.Key.Number);
                        if (idx > 0)
                        {
                            m_ArrayMap.Remove(idx);
                            continue;
                        }
                    }

                    if (node.Value.Key.Type == DataType.String)
                    {
                        m_StringMap.Remove(node.Value.Key.String);
                    }
                    else
                    {
                        m_ValueMap.Remove(node.Value.Key);
                    }
                }
            }
        }
        private bool PerformTableRemove <T>(LinkedListIndex <T, TablePair> listIndex, T key, bool isNumber)
        {
            var removed = listIndex.Remove(key);

            if (removed && isNumber)
            {
                m_CachedLength = -1;
            }

            return(removed);
        }
Exemple #3
0
        private bool PerformTableRemove <T>(LinkedListIndex <T, TablePair> listIndex, T key, bool isNumber)
        {
            if (!_isAlive)
            {
                throw new InvalidOperationException(string.Format("Attempting to PerformTableRemove on dead Table"));
            }
            var removed = listIndex.Remove(key);

            if (removed && isNumber)
            {
                m_CachedLength = -1;
            }

            return(removed);
        }