Merge pull request #8972 from skilchen/more_efficient_fix_for_8961

more efficient fix for #8961
This commit is contained in:
Andreas Rumpf 2018-09-15 17:31:03 +02:00 • committed by GitHub
commit 2745111fc3
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -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