169
170
171
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
|
if rc < int(available) && err == nil {
// Retry the read if we have fewer bytes than what the prediction header indicates
var r int
r, err = reader.Read(ctx.input[predicted+rc:])
rc += r
goto retryData
} // Continue on any error, try to decompress and return it along the result
// Walk the buffer, filling in the predicted blanks,
// relocating read bytes and and updating the guess table
for i, a := uint(0), predicted; i < 8; i++ {
if (flags & (1 << i)) > 0 {
// Guess succeeded, fill in from the table
ctx.input[i] = ctx.table[ctx.hash]
rc++
} else {
// Relocate a read byte
ctx.input[i], a = ctx.input[a], a+1
// Guess failed, update the table
ctx.table[ctx.hash] = ctx.input[i]
}
// Update the hash
ctx.hash = (ctx.hash << 4) ^ uint16(ctx.input[i])
}
// rc now contains the precise amount of populated data
ctx.input = ctx.input[:rc]
available = copy(output, ctx.input)
total += available
// Check for remaining bytes that dont fit in the output buffer
if available < rc {
|
>
>
>
|
|
<
|
|
169
170
171
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
|
if rc < int(available) && err == nil {
// Retry the read if we have fewer bytes than what the prediction header indicates
var r int
r, err = reader.Read(ctx.input[predicted+rc:])
rc += r
goto retryData
} // Continue on any error, try to decompress and return it along the result
// rc now contains the amount of actual bytes in this cycle (usually 8)
rc += predicted
// Walk the buffer, filling in the predicted blanks,
// relocating read bytes and and updating the guess table
for i, a := 0, predicted; i < rc; i++ {
if (flags & (1 << uint(i))) > 0 {
// Guess succeeded, fill in from the table
ctx.input[i] = ctx.table[ctx.hash]
} else {
// Relocate a read byte
ctx.input[i], a = ctx.input[a], a+1
// Guess failed, update the table
ctx.table[ctx.hash] = ctx.input[i]
}
// Update the hash
ctx.hash = (ctx.hash << 4) ^ uint16(ctx.input[i])
}
// Copy the decompressed data to the output
ctx.input = ctx.input[:rc]
available = copy(output, ctx.input)
total += available
// Check for remaining bytes that dont fit in the output buffer
if available < rc {
|