RTools.Util.CharBuffer.CheckCapacity C# (CSharp) Method

CheckCapacity() protected method

Ensure that we're set for the requested length by potentially growing or shifting contents.
protected CheckCapacity ( int requestedLength ) : void
requestedLength int
return void
        protected void CheckCapacity(int requestedLength)
        {
            if (requestedLength + headIndex >= capacity)
            {
                // have to do something
                if ((requestedLength + headIndex > (capacity >> 1))
                    && (requestedLength < capacity - 1))
                {
                    // we're more than half-way through the buffer, and shifting is enough
                    // so just shift
                    ShiftToZero();
                }
                else
                {
                    // not far into buffer or shift wouldn't be enough anyway
                    Grow(0);
                }
            }
        }