private void EnsureCapacity(int capacity) { Debug.Assert(capacity >= 1); // Make sure we have the necessary space in m_Actions. In case we're currently using m_Actions // from another InputActionMap, this will automatically switch to a new array as the array // from the map won't have any space left. // // That is, except if we popped actions off the back. In that case we need to duplicate now // or we'd write into the array of the action map and stomp over its actions. if ((m_Flags & Flags.UsingActionArrayOfMap) != 0 && m_Actions != null && m_Actions.Length > m_ActionCount) { ArrayHelpers.DuplicateWithCapacity(ref m_Actions, m_ActionCount, capacity); } else { ArrayHelpers.EnsureCapacity(ref m_Actions, m_ActionCount, capacity); } // We always end up with an array of our own. m_Flags &= ~Flags.UsingActionArrayOfMap; }