Dont convert string to cstring when writing to stream.

This commit is contained in:
Yuriy Glukhov
2016-01-20 23:52:14 +02:00
parent c527969059
commit df211b24fd

View File

@@ -148,7 +148,10 @@ proc write*[T](s: Stream, x: T) =
proc write*(s: Stream, x: string) =
## writes the string `x` to the the stream `s`. No length field or
## terminating zero is written.
writeData(s, cstring(x), x.len)
when nimvm:
writeData(s, cstring(x), x.len)
else:
if x.len > 0: writeData(s, unsafeAddr x[0], x.len)
proc writeLn*(s: Stream, args: varargs[string, `$`]) {.deprecated.} =
## **Deprecated since version 0.11.4:** Use **writeLine** instead.