Diff

Differences From Artifact [2d2f3f4577]:

To Artifact [bc261fa076]:


69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
			length += 2
			continue
		}

		value >>= 1
		length++
	}
	result += f[length] - 1
	return
}

func Writer(target io.Writer) io.Writer {
	var enc encoder
	enc.Numbers = New(16)
	enc.target = target
	enc.buffer = enc.backing[:0:len(enc.backing)]
	return &enc
}

type encoder struct {
	Numbers
	target    io.Writer
	backing   [3]byte // TODO - verify that this can be reduced to 2 bytes
	buffer    []byte
	remaining byte
	length    byte
}

func (e *encoder) Write(input []byte) (int, error) {
	var (







|
<




|








|







69
70
71
72
73
74
75
76

77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
			length += 2
			continue
		}

		value >>= 1
		length++
	}
	return result + f[length] - 1, length + 1

}

func Writer(target io.Writer) io.Writer {
	var enc encoder
	enc.Numbers = New(14)
	enc.target = target
	enc.buffer = enc.backing[:0:len(enc.backing)]
	return &enc
}

type encoder struct {
	Numbers
	target    io.Writer
	backing   [2]byte
	buffer    []byte
	remaining byte
	length    byte
}

func (e *encoder) Write(input []byte) (int, error) {
	var (
173
174
175
176
177
178
179




























180
181
// 	Numbers
// 	source io.Reader
// 	buffer uint64
// 	at     byte
// }

// func (d *decoder) Read(output []byte) (int, error) {




























// 	return 0, nil
// }







>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
|

172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
// 	Numbers
// 	source io.Reader
// 	buffer uint64
// 	at     byte
// }

// func (d *decoder) Read(output []byte) (int, error) {
// 	var (
// 		total int
// 		err   error
// 	)

// 	// While we have suitable buffered data and enough output space
// 	for (len(output) > 0) && ((d.buffer & (d.buffer >> 1)) > 0) {
// 		val, len := d.Decode(d.buffer)

// 		// Store the decoded byte
// 		output[0] = byte(val)

// 		// Advance the internal and output buffers
// 		output = output[1:]
// 		d.buffer >>= len

// 		// TODO - decrease d.at as well ?

// 		total++
// 	}

// 	// Termination condition
// 	if len(output) == 0 {
// 		return total, nil
// 	}

// 	// count, err := d.source.Read(output)

// 	return total, err
// }