else if (rmSize > addSize) { removeImpl(position + addSize, rmSize - addSize); } else { int endSize = addSize - rmSize; int end = addImpl(position + rmSize, endSize); System.arraycopy(addItems, rmSize, buffer, end, endSize); addSize = rmSize; } System.arraycopy(addItems, 0, buffer, position, addSize);
  protected void replace(int position, int rmSize, Object addItems,                         int addSize)  {    if (gapStart != position)      shiftGap(position);          // Remove content    if (rmSize > 0)    shiftGapEndUp(gapEnd + rmSize);    // If gap is too small, enlarge the gap.    if ((gapEnd - gapStart) <= addSize)      shiftEnd((addSize - gapEnd + gapStart + 1) * 2 + gapEnd + DEFAULT_BUFSIZE);    // Add new items to the buffer.    if (addItems != null)      {        System.arraycopy(addItems, 0, buffer, gapStart, addSize);                        resetMarksAtZero();                gapStart += addSize;      }  }