Diff

## To Artifact [4b4dfe919b]:

```   128    128
129    129   			continue
130    130   		}
131    131
132    132   		// Clearing e.length is not necessary as it will be overwritten later
133    133
134    134   		// Stage the complete byte for writing
135         -		buffer := []byte{byte(e.remaining)}
135  +		buffer := make([]byte, 1, 2)
136  +		buffer[0] = byte(e.remaining)
136    137
137    138   		// Stage every full byte from the encoded value for writing
138         -		for enc > 128 {
139  +		//
140  +		// The bitlength of the largest encoded byte value, 255, is 13.
141  +		// Even with 7 bits already in the buffer this leaves [7+1], [8]
142  +		// and 4 bits remaining => a single if is enough instead of a for.
143  +		//
144  +		// 128 is [1000 0000] in binary. Any value equal or greater than it
145  +		// will be atleast 8 bits in length
146  +		if enc >= 128 {
139    147   			buffer = append(buffer, byte(enc))
140    148   			enc >>= 8
141    149   			len -= 8
142    150   		}
143    151
144    152   		// Store the remaining bits
145    153   		e.remaining, e.length = byte(enc), len
................................................................................
187    195   		output[0] = byte(val)
188    196
189    197   		// Advance the internal and output buffers
190    198   		output = output[1:]
191    199   		d.buffer >>= len
192    200   		d.at -= len
193    201
202  +		// Account for the processed output byte
194    203   		total++
195    204   	}
196    205
197    206   	// Termination condition
198    207   	if len(output) == 0 || err != nil {
200    209   	}
201    210
202    211   	// We need to limit the output's size else we could end up with a lot of small values
203    212   	// that fit neither in the output slice nor in the internal buffer
213  +	//
214  +	// (63 is [0011 1111] in binary, xor is a substraction and right shift a division)
204    215   	free := int((63 ^ d.at) >> 3)
205    216   	if free > len(output) {
206    217   		free = len(output)
207    218   	}
208    219
209    220   	// Read data and transfer to the internal buffer
210    221   	count, err := d.source.Read(output[:free])

```