Review 371e60b17c and apply fixes
This commit is contained in:
parent
1eef0ec19c
commit
94fa3fab8c
2 changed files with 6 additions and 7 deletions
|
|
@ -808,13 +808,10 @@ template readIntoExImpl(s: InputStream,
|
||||||
let totalBytesDrained = drainBuffersInto(s, dst, dstLen)
|
let totalBytesDrained = drainBuffersInto(s, dst, dstLen)
|
||||||
var bytesDeficit = (dstLen - totalBytesDrained)
|
var bytesDeficit = (dstLen - totalBytesDrained)
|
||||||
|
|
||||||
if bytesDeficit > 0:
|
if bytesDeficit > 0 and s.vtable != nil:
|
||||||
var adjustedDst = offset(dst, totalBytesDrained)
|
var adjustedDst = offset(dst, totalBytesDrained)
|
||||||
|
|
||||||
while true:
|
while true:
|
||||||
if s.vtable.isNil():
|
|
||||||
break
|
|
||||||
|
|
||||||
let newBytesRead = awaiter s.vtable.readOp(s, adjustedDst, bytesDeficit)
|
let newBytesRead = awaiter s.vtable.readOp(s, adjustedDst, bytesDeficit)
|
||||||
|
|
||||||
s.spanEndPos += newBytesRead
|
s.spanEndPos += newBytesRead
|
||||||
|
|
|
||||||
|
|
@ -20,10 +20,12 @@ proc repeat(b: byte, count: int): seq[byte] =
|
||||||
result = newSeq[byte](count)
|
result = newSeq[byte](count)
|
||||||
for i in 0 ..< count: result[i] = b
|
for i in 0 ..< count: result[i] = b
|
||||||
|
|
||||||
|
const line = "123456789123456789123456789123456789\n\n\n\n\n"
|
||||||
|
|
||||||
proc randomBytes(n: int): seq[byte] =
|
proc randomBytes(n: int): seq[byte] =
|
||||||
result.newSeq n
|
result.newSeq n
|
||||||
for i in 0 ..< n:
|
for i in 0 ..< n:
|
||||||
result[i] = byte(rand(int('1')..int('9')))
|
result[i] = byte(rand(line))
|
||||||
|
|
||||||
proc readAllAndClose(s: InputStream): seq[byte] =
|
proc readAllAndClose(s: InputStream): seq[byte] =
|
||||||
while s.readable:
|
while s.readable:
|
||||||
|
|
@ -53,8 +55,8 @@ suite "output stream":
|
||||||
streamWritingToExistingBuffer = unsafeMemoryOutput(buffer, bufferSize)
|
streamWritingToExistingBuffer = unsafeMemoryOutput(buffer, bufferSize)
|
||||||
|
|
||||||
teardown:
|
teardown:
|
||||||
fileStream.close()
|
close fileStream
|
||||||
unbufferedFileStream.close()
|
close unbufferedFileStream
|
||||||
removeFile fileOutputPath
|
removeFile fileOutputPath
|
||||||
removeFile unbufferedFileOutputPath
|
removeFile unbufferedFileOutputPath
|
||||||
dealloc buffer
|
dealloc buffer
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue