Minimize output stream allocations

Addresses issues #779 and #775. Added a Protocol stream benchmark and measured a 73% increase for Multi Bulk and 87% increase for Status Reply.  The greatly reduces the number of temporary objects created and encoded for reading results. It also ensures that we will hear about it if a stream is not fully read. In the currently implementation a stream error could cause readByte to return -1 even though a byte is required by the protocol. All unit tests and benchmarks pass.
Exactly!

On Wed, Oct 22, 2014 at 3:23 PM, Jungtaek Lim <notifications@github.com>
wrote:

> In src/main/java/redis/clients/util/RedisInputStream.java:
>
> > -		return -1;
> > +    public byte[] readLineBytes() {
> > +
> > +	/* This operation should only require one fill. In that typical
> > +	case we optimize allocation and copy of the byte array. In the
> > +	edge case where more than one fill is required then we take a
> > +	slower path and expand a byte array output stream as is
> > +	necessary. */
> > +
> > +	ensureFill();
> > +
> > +	int pos = count;
> > +	final byte[] buf = this.buf;
> > +	while (true) {
> > +	    if (pos == limit) {
> > +		return readLineBytesSlowly();
>
> We're safe to use it because readLineBytes() uses different position var
> to not modifying global position, right?
>
> —
> Reply to this email directly or view it on GitHub
> <https://github.com/xetorthio/jedis/pull/780/files#r19248744>.
>