mirror of
https://github.com/status-im/nim-libp2p.git
synced 2025-03-02 05:20:43 +00:00
address review comments
This commit is contained in:
parent
9b7e1c6515
commit
40ab9ff6d1
@ -44,14 +44,9 @@ method readOnce*(stream: QuicStream,
|
|||||||
nbytes: int): Future[int] {.async.} =
|
nbytes: int): Future[int] {.async.} =
|
||||||
if stream.cached.len == 0:
|
if stream.cached.len == 0:
|
||||||
stream.cached = await mapExceptions(stream.stream.read())
|
stream.cached = await mapExceptions(stream.stream.read())
|
||||||
if stream.cached.len <= nbytes:
|
result = min(nbytes, stream.cached.len)
|
||||||
copyMem(pbytes, addr stream.cached[0], stream.cached.len)
|
copyMem(pbytes, addr stream.cached[0], result)
|
||||||
result = stream.cached.len
|
stream.cached = stream.cached[result..^1]
|
||||||
stream.cached = @[]
|
|
||||||
else:
|
|
||||||
copyMem(pbytes, addr stream.cached[0], nbytes)
|
|
||||||
result = nbytes
|
|
||||||
stream.cached = stream.cached[nbytes..^1]
|
|
||||||
|
|
||||||
{.push warning[LockLevel]: off.}
|
{.push warning[LockLevel]: off.}
|
||||||
method write*(stream: QuicStream, bytes: seq[byte]) {.async.} =
|
method write*(stream: QuicStream, bytes: seq[byte]) {.async.} =
|
||||||
|
Loading…
x
Reference in New Issue
Block a user