120
121
122
123
124
125
126
127
128
129
130
131
132
133
|
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
|
+
+
+
|
// Shift the the encoded value and account for its length
enc >>= added
e.length += len
len -= added
// Not enough bits to write
if e.length < 8 {
// Account for the processed input byte
total++
continue
}
// Clearing e.length is not necessary as it will be overwritten later
// Stage the complete byte for writing
e.buffer = append(e.buffer, byte(e.remaining))
|
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
|
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
|
-
+
|
_, err = e.target.Write(e.buffer)
// Abort write on error
if err != nil {
break
}
// Account for the just-written byte
// Account for the processed input byte
total++
// Clear the buffer
e.buffer = e.buffer[:0]
}
return total, err
}
|