diff options
-rw-r--r-- | lib/pure/streams.nim | 11 |
1 files changed, 6 insertions, 5 deletions
diff --git a/lib/pure/streams.nim b/lib/pure/streams.nim index 68f31e9fe..88ac626a6 100644 --- a/lib/pure/streams.nim +++ b/lib/pure/streams.nim @@ -103,15 +103,16 @@ proc readData*(s: Stream, buffer: pointer, bufLen: int): int = proc readAll*(s: Stream): string = ## Reads all available data. - result = newString(1000) + let bufferSize = 1000 + result = newString(bufferSize) var r = 0 while true: - let readBytes = readData(s, addr(result[r]), 1000) - if readBytes < 1000: + let readBytes = readData(s, addr(result[r]), bufferSize) + if readBytes < bufferSize: setLen(result, r+readBytes) break - inc r, 1000 - setLen(result, r+1000) + inc r, bufferSize + setLen(result, r+bufferSize) proc readData*(s, unused: Stream, buffer: pointer, bufLen: int): int {.deprecated.} = |