summary refs log tree commit diff stats
diff options
context:
space:
mode:
authorAndreas Rumpf <rumpf_a@web.de>2018-09-15 17:31:03 +0200
committerGitHub <noreply@github.com>2018-09-15 17:31:03 +0200
commit2745111fc333d58f663480639aae5b2e0e0e1636 (patch)
treee2d459d071d0dba13bd519196a44d12f7cee58a4
parent4342b79a3c05fcfb1e6fc97152daa0075b0b9603 (diff)
parente317745098b95418bc1bc3d76b930ab197d67110 (diff)
downloadNim-2745111fc333d58f663480639aae5b2e0e0e1636.tar.gz
Merge pull request #8972 from skilchen/more_efficient_fix_for_8961
more efficient fix for #8961
-rw-r--r--lib/system/sysio.nim7
1 files changed, 3 insertions, 4 deletions
diff --git a/lib/system/sysio.nim b/lib/system/sysio.nim
index df13ab628..61835e0f7 100644
--- a/lib/system/sysio.nim
+++ b/lib/system/sysio.nim
@@ -145,10 +145,9 @@ proc readLine(f: File, line: var TaintedString): bool =
   var pos = 0
 
   # Use the currently reserved space for a first try
-  var sp = line.string.len
-  if sp == 0:
-    sp = 80
-    line.string.setLen(sp)
+  var sp = max(line.string.len, 80)
+  line.string.setLen(sp)
+
   while true:
     # memset to \L so that we can tell how far fgets wrote, even on EOF, where
     # fgets doesn't append an \L