code: public void ensureCapacity(int capacity) {
      if (capacity > buf.length) {
        int factor = buf.length / 2 + 1;
        grow(calcSize(capacity - buf.length, factor));
      }
    }
docs: Ensures that there is at least {@code l} capacity.
  
  @param capacity the minimal capacity.