mirror of
https://github.com/ddidderr/wuffs.git
synced 2026-11-26 17:01:35 +01:00
Tweak how rac.concReader.Read moves to next work
This commit is contained in:
1 parent
cb40bbc26c
commit
0a31851d85
1 file changed
+8
-15
+8
-15
@@ -230,28 +230,21 @@ func (c *concReader) Read(p []byte) (int, error) {
|
|||||||
if len(p) == 0 {
|
if len(p) == 0 {
|
||||||
return numRead, nil
|
return numRead, nil
|
||||||
}
|
}
|
||||||
|
if c.currWork.i >= c.currWork.j {
|
||||||
|
err := c.currWork.err
|
||||||
|
c.currWork.recycle()
|
||||||
|
if err != nil {
|
||||||
|
return numRead, err
|
||||||
|
}
|
||||||
|
c.currWork = c.nextWork()
|
||||||
|
}
|
||||||
|
|
||||||
// Fill p from c.currWork.
|
// Fill p from c.currWork.
|
||||||
if c.currWork.i < c.currWork.j {
|
|
||||||
n := copy(p, c.currWork.buffer[c.currWork.i:c.currWork.j])
|
n := copy(p, c.currWork.buffer[c.currWork.i:c.currWork.j])
|
||||||
p = p[n:]
|
p = p[n:]
|
||||||
numRead += n
|
numRead += n
|
||||||
c.pos += int64(n)
|
c.pos += int64(n)
|
||||||
c.currWork.i += uint32(n)
|
c.currWork.i += uint32(n)
|
||||||
err := c.currWork.err
|
|
||||||
|
|
||||||
// Recycle c.currWork if we're done with it.
|
|
||||||
if c.currWork.i >= c.currWork.j {
|
|
||||||
c.currWork.recycle()
|
|
||||||
}
|
|
||||||
|
|
||||||
if err != nil {
|
|
||||||
return numRead, err
|
|
||||||
}
|
|
||||||
continue
|
|
||||||
}
|
|
||||||
|
|
||||||
c.currWork = c.nextWork()
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in new issue
Block a user