summary refs log tree commit diff stats
path: root/lib/pure
diff options
context:
space:
mode:
authorRadu Oana <radu.oana@ericsson.com>2015-09-30 08:20:24 -0400
committerRadu Oana <radu.oana@ericsson.com>2015-09-30 08:20:24 -0400
commit374b65289c258b2c33f6087b87b336dc5908b9d9 (patch)
tree68ba1f0c45ae56b5b79f7c1fb7b5fb1a6b0fb6d0 /lib/pure
parent4071219e201d76d75a95ce712027aac1d2ee5281 (diff)
downloadNim-374b65289c258b2c33f6087b87b336dc5908b9d9.tar.gz
Move magic numbers to const
Diffstat (limited to 'lib/pure')
-rw-r--r--lib/pure/streams.nim11
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.} =