Helios.Util.InternalThreadLocalMap.ExpandIndexedVariableTableAndSet C# (CSharp) Method

ExpandIndexedVariableTableAndSet() private method

private ExpandIndexedVariableTableAndSet ( int index, object value ) : void
index int
value object
return void
        void ExpandIndexedVariableTableAndSet(int index, object value)
        {
            object[] oldArray = this.indexedVariables;
            int oldCapacity = oldArray.Length;
            int newCapacity = index;
            newCapacity |= newCapacity.RightUShift(1);
            newCapacity |= newCapacity.RightUShift(2);
            newCapacity |= newCapacity.RightUShift(4);
            newCapacity |= newCapacity.RightUShift(8);
            newCapacity |= newCapacity.RightUShift(16);
            newCapacity++;

            var newArray = new object[newCapacity];
            oldArray.CopyTo(newArray, 0);
            newArray.Fill(oldCapacity, newArray.Length - oldCapacity, Unset);
            newArray[index] = value;
            this.indexedVariables = newArray;
        }