137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
|
// Check whether we have leftover data in the buffer
if len(ctx.input) > 0 {
readCount = copy(output, ctx.input)
// Check whether we still have leftover data in the buffer :)
if readCount < len(ctx.input) {
copy(ctx.input[:readCount], ctx.input[readCount:])
ctx.input = ctx.input[:readCount]
}
return readCount, nil
}
// This is single-iteration only but it is fine according to io.Reader's contract ?!
// TODO - read all bytes from a block based on the hamming weight of the flag
// and just shuffle them for predictions instead of bite-sized reads ;)
|
<
|
|
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
|
// Check whether we have leftover data in the buffer
if len(ctx.input) > 0 {
readCount = copy(output, ctx.input)
// Check whether we still have leftover data in the buffer :)
if readCount < len(ctx.input) {
ctx.input = ctx.input[:copy(ctx.input, ctx.input[readCount:])]
}
return readCount, nil
}
// This is single-iteration only but it is fine according to io.Reader's contract ?!
// TODO - read all bytes from a block based on the hamming weight of the flag
// and just shuffle them for predictions instead of bite-sized reads ;)
|