mirror of https://github.com/vacp2p/nim-libp2p.git
avoid a few zeroMem (#932)
This commit is contained in:
parent
1721f078c7
commit
fab1340020
|
@ -276,7 +276,7 @@ proc readLp*(s: LPStream, maxSize: int): Future[seq[byte]] {.async, gcsafe, publ
|
|||
if length == 0:
|
||||
return
|
||||
|
||||
var res = newSeq[byte](length)
|
||||
var res = newSeqUninitialized[byte](length)
|
||||
await s.readExactly(addr res[0], res.len)
|
||||
return res
|
||||
|
||||
|
|
|
@ -43,7 +43,7 @@ proc initVBuffer*(data: seq[byte], offset = 0): VBuffer =
|
|||
|
||||
proc initVBuffer*(data: openArray[byte], offset = 0): VBuffer =
|
||||
## Initialize VBuffer with copy of ``data``.
|
||||
result.buffer = newSeq[byte](len(data))
|
||||
result.buffer = newSeqUninitialized[byte](len(data))
|
||||
if len(data) > 0:
|
||||
copyMem(addr result.buffer[0], unsafeAddr data[0], len(data))
|
||||
result.offset = offset
|
||||
|
|
Loading…
Reference in New Issue