Resize buffers only if necessary
492720
def _resize_buffers(self, font_scale):
        """"""
        new_sizes = (font_scale,) + self.size
        if new_sizes == self._current_sizes:  # don't need resize
            return
        self._n_rows = int(max(self.size[1] /
                               (self._char_height * font_scale), 1))
        self._n_cols = int(max(self.size[0] /
                               (self._char_width * font_scale), 1))
        self._bytes_012 = np.zeros((self._n_rows, self._n_cols, 3), np.float32)
        self._bytes_345 = np.zeros((self._n_rows, self._n_cols, 3), np.float32)
        pos = np.empty((self._n_rows, self._n_cols, 2), np.float32)
        C, R = np.meshgrid(np.arange(self._n_cols), np.arange(self._n_rows))
        # We are in left, top orientation
        x_off = 4.
        y_off = 4 - self.size[1] / font_scale
        pos[..., 0] = x_off + self._char_width * C
        pos[..., 1] = y_off + self._char_height * R
        self._position = VertexBuffer(pos)

        # Restore lines
        for ii, line in enumerate(self._text_lines[:self._n_rows]):
            self._insert_text_buf(line, ii)
        self._current_sizes = new_sizes
1019788
private void resizeTo( int length )
    {
        if ( length <= 0 )
            throw new IllegalArgumentException("length <= 0");
        
        if ( length != buff.length ) {
            int len = ( length > buff.length ) ? buff.length : length;
            //System.out.println("resize:"+length);
            char[] obuff = buff;
            buff = new char[length];
            /*for ( int j = 0; j < len; j++ ) {
                buff[j] = obuff[j];
            }*/
            System.arraycopy(obuff, 0, buff, 0, len);
        }
    }
1169346
def clear(self, fill = 0x00):
        
        self._buffer = [ fill ] * ( self.width * self.height )
941897
def enable_buffering(self, size=5):
        """"""
        if size <= 1:
            raise ValueError('buffer size too small')

        def generator(next):
            buf = []
            c_size = 0
            push = buf.append

            while 1:
                try:
                    while c_size < size:
                        c = next()
                        push(c)
                        if c:
                            c_size += 1
                except StopIteration:
                    if not c_size:
                        return
                yield concat(buf)
                del buf[:]
                c_size = 0

        self.buffered = True
        self._next = generator(self._gen.next).next
1058909
private byte[] resizeBuffer(final Context context) {
        if (context.buffer == null) {
            context.buffer = new byte[getDefaultBufferSize()];
            context.pos = 0;
            context.readPos = 0;
        } else {
            final byte[] b = new byte[context.buffer.length * DEFAULT_BUFFER_RESIZE_FACTOR];
            System.arraycopy(context.buffer, 0, b, 0, context.buffer.length);
            context.buffer = b;
        }
        return context.buffer;
    }
1152390
public static <T> T[] resize(T[] buffer, int newSize) {
		return resize(buffer, newSize, buffer.getClass().getComponentType());
	}
495462
function ensureBufferSize(buffer, minimumSize, contentSize) {
        if (buffer.length >= minimumSize) {
            return buffer;
        }
        var newBuffer = new Buffer(minimumSize);
        if (contentSize) {
            buffer.copy(newBuffer, 0, 0, contentSize);
        } else {
            buffer.copy(newBuffer);
        }
        return newBuffer;
    }
31259
public void compress() {
        resizeLock.lock();
        try {
            AtomicShortIntBackingArray s = store.get();
            if (s instanceof AtomicShortIntUniformBackingArray) {
                return;
            }
            int unique = s.getUnique();
            if (AtomicShortIntPaletteBackingArray.roundUpWidth(unique - 1) >= s.width()) {
                return;
            }
            if (unique > AtomicShortIntPaletteBackingArray.getAllowedPalette(s.length())) {
                return;
            }
            if (unique == 1) {
                store.set(new AtomicShortIntUniformBackingArray(s));
            } else {
                store.set(new AtomicShortIntPaletteBackingArray(s, length, true, false, unique));
            }
        } finally {
            resizeLock.unlock();
        }
    }
1209564
def set_write_buffer_limits(self, high=None, low=None):
        """"""
        if high is None:
            high = self.write_buffer_size
        if low is None:
            low = high // 2
        if low > high:
            low = high
        self._write_buffer_high = high
        self._write_buffer_low = low
366616
private void reallocateBuffer(int newCapacity) {

        byte[] newBuffer = new byte[newCapacity];
        System.arraycopy(m_buffer, 0, newBuffer, 0, Math.min(m_size, newCapacity));
        m_buffer = newBuffer;
    }
1323990
def _configure_buffer_sizes():
    """"""
    global PIPE_BUF_BYTES
    global OS_PIPE_SZ

    PIPE_BUF_BYTES = 65536
    OS_PIPE_SZ = None

    # Teach the 'fcntl' module about 'F_SETPIPE_SZ', which is a Linux-ism,
    # but a good one that can drastically reduce the number of syscalls
    # when dealing with high-throughput pipes.
    if not hasattr(fcntl, 'F_SETPIPE_SZ'):
        import platform

        if platform.system() == 'Linux':
            fcntl.F_SETPIPE_SZ = 1031

    # If Linux procfs (or something that looks like it) exposes its
    # maximum F_SETPIPE_SZ, adjust the default buffer sizes.
    try:
        with open('/proc/sys/fs/pipe-max-size', 'r') as f:
            # Figure out OS pipe size, but in case it is unusually large
            # or small restrain it to sensible values.
            OS_PIPE_SZ = min(int(f.read()), 1024 * 1024)
            PIPE_BUF_BYTES = max(OS_PIPE_SZ, PIPE_BUF_BYTES)
    except Exception:
        pass
1346914
@Override
  public void ensureCapacity(int expectedElements) {
    if (expectedElements > resizeAt || keys == null) {
      final KType[] prevKeys = Intrinsics.<KType[]> cast(this.keys);
      allocateBuffers(minBufferSize(expectedElements, loadFactor));
      if (prevKeys != null && !isEmpty()) {
        rehash(prevKeys);
      }
    }
  }
88839
function updateGreyColorBuffer(buf) {
  for (let i = 0; i < buf.length; ++i) {
    buf[i] = 0.5;
  }
  return buf;
}
816398
private void cleanupDecBuffers() {
        // if we have decrypted buffers and they are either JIT created or made
        // during decryption/expansion (user buffers too small) then release them
        // here and dereference
        if (null != this.decryptedNetBuffers
            && (callerRequiredAllocation || decryptedNetBufferReleaseRequired)) {
            WsByteBufferUtils.releaseBufferArray(this.decryptedNetBuffers);
            this.decryptedNetBuffers = null;
        }
    }
631196
private void removeBuffers() {
		IntBuffer buffer = BufferUtils.createIntBuffer(1);
		int queued = AL10.alGetSourcei(source, AL10.AL_BUFFERS_QUEUED);
		
		while (queued > 0)
		{
			AL10.alSourceUnqueueBuffers(source, buffer);
			queued--;
		}
	}
1038014
def update_buffer(self, ms):
        """"""
        librtmp.RTMP_SetBufferMS(self.client.rtmp, int(ms))
        librtmp.RTMP_UpdateBufferMS(self.client.rtmp)
1269273
function setBuffer(newSize) {
		// Add 1 byte of padding to the buffer to make the overall implementation easier
		var oldLength = self.length;
		var newBuffer = new Buffer(newSize + 1);
		newBuffer.fill(0);
		if (buffer instanceof Buffer) self.copy(newBuffer);
		buffer = newBuffer;
		head = 0;
		tail = oldLength || 0;
	}