add io.readChars overload (simpler, less error prone) (#16044)

* add simpler to use readChars overload

* use new readChars overload

* Update lib/wrappers/openssl.nim

Co-authored-by: Andreas Rumpf <rumpf_a@web.de>
Co-authored-by: flywind <xzsflywind@gmail.com>
This commit is contained in:
Timothee Cour 2021-02-22 11:13:08 -08:00 • committed by GitHub
commit ce7caec4b3
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
5 changed files with 50 additions and 6 deletions

View file

@ -231,7 +231,7 @@ proc secureHashFile*(filename: string): SecureHash =
var state = newSha1State()
var buffer = newString(BufferLength)
while true:
let length = readChars(f, buffer, 0, BufferLength)
let length = readChars(f, buffer)
if length == 0:
break
buffer.setLen(length)