streams.ssWriteData: calling setLen only when new data truely increases the underlying string buffer
This commit is contained in:
parent
549920a85f
commit
f9b2f9565c
1 changed files with 5 additions and 3 deletions
|
|
@ -224,7 +224,9 @@ proc ssReadData(s: Stream, buffer: pointer, bufLen: int): int =
|
||||||
|
|
||||||
proc ssWriteData(s: Stream, buffer: pointer, bufLen: int) =
|
proc ssWriteData(s: Stream, buffer: pointer, bufLen: int) =
|
||||||
var s = StringStream(s)
|
var s = StringStream(s)
|
||||||
if bufLen > 0:
|
if bufLen <= 0:
|
||||||
|
return
|
||||||
|
if s.pos + bufLen > s.data.len():
|
||||||
setLen(s.data, s.data.len + bufLen)
|
setLen(s.data, s.data.len + bufLen)
|
||||||
copyMem(addr(s.data[s.pos]), buffer, bufLen)
|
copyMem(addr(s.data[s.pos]), buffer, bufLen)
|
||||||
inc(s.pos, bufLen)
|
inc(s.pos, bufLen)
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue