Antlr4.Runtime.UnbufferedCharStream.Release C# (CSharp) Method

Release() public method

Decrement number of markers, resetting buffer if we hit 0.
public Release ( int marker ) : void
marker int
return void
        public virtual void Release(int marker)
        {
            int expectedMark = -numMarkers;
            if (marker != expectedMark)
            {
                throw new InvalidOperationException("release() called with an invalid marker.");
            }
            numMarkers--;
            if (numMarkers == 0 && p > 0)
            {
                // release buffer when we can, but don't do unnecessary work
                // Copy data[p]..data[n-1] to data[0]..data[(n-1)-p], reset ptrs
                // p is last valid char; move nothing if p==n as we have no valid char
                System.Array.Copy(data, p, data, 0, n - p);
                // shift n-p char from p to 0
                n = n - p;
                p = 0;
                lastCharBufferStart = lastChar;
            }
        }