コード例 #1
0
        private void PerformTableSet <T>(LinkedListIndex <T, TablePair> listIndex, T key, DynValue keyDynValue, DynValue value, bool isNumber, int appendKey)
        {
            if (!_isAlive)
            {
                throw new InvalidOperationException(string.Format("Attempting to PerformTableSet on dead Table"));
            }
            TablePair prev = listIndex.Set(key, new TablePair(keyDynValue, value));

            // If this is an insert, we can invalidate all iterators and collect dead keys
            if (m_ContainsNilEntries && value.IsNotNil() && (prev.Value.IsNil()))
            {
                CollectDeadKeys();
            }
            // If this value is nil (and we didn't collect), set that there are nil entries, and invalidate array len cache
            else if (value.IsNil())
            {
                m_ContainsNilEntries = true;

                if (isNumber)
                {
                    m_CachedLength = -1;
                }
            }
            else if (isNumber)
            {
                // If this is an array insert, we might have to invalidate the array length
                if (prev.Value.IsNilOrNan())
                {
                    // If this is an array append, let's check the next element before blindly invalidating
                    if (appendKey >= 0)
                    {
                        if (m_ArrayMap == null)
                        {
                            m_CachedLength += 1;
                        }
                        else
                        {
                            LinkedListNode <TablePair> next = m_ArrayMap.Find(appendKey + 1);
                            if (next == null || next.Value.Value.IsNil())
                            {
                                m_CachedLength += 1;
                            }
                            else
                            {
                                m_CachedLength = -1;
                            }
                        }
                    }
                    else
                    {
                        m_CachedLength = -1;
                    }
                }
            }
        }
コード例 #2
0
        private void PerformTableSet <T>(LinkedListIndex <T, TablePair> listIndex, T key, DynValue keyDynValue, DynValue value, bool isNumber)
        {
            TablePair prev = listIndex.Set(key, new TablePair(keyDynValue, value));

            if (prev.Value == null || prev.Value.IsNil())
            {
                CollectDeadKeys();

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

            if (isNumber && value.IsNil())
            {
                m_CachedLength = -1;
            }
        }