diff options
author | Yuriy Glukhov <yuriy.glukhov@gmail.com> | 2016-01-20 23:52:14 +0200 |
---|---|---|
committer | Yuriy Glukhov <yuriy.glukhov@gmail.com> | 2016-01-21 11:41:52 +0200 |
commit | df211b24fdc221175fb0ce4dfef12a5293ed0c37 (patch) | |
tree | 90d563e4baac4612f497012a62c505868990fde9 | |
parent | c52796905958550e70ede4a69ff7bb8a8050d037 (diff) | |
download | Nim-df211b24fdc221175fb0ce4dfef12a5293ed0c37.tar.gz |
Dont convert string to cstring when writing to stream.
-rw-r--r-- | lib/pure/streams.nim | 5 |
1 files changed, 4 insertions, 1 deletions
diff --git a/lib/pure/streams.nim b/lib/pure/streams.nim index 38e91fee4..bb6175a12 100644 --- a/lib/pure/streams.nim +++ b/lib/pure/streams.nim @@ -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. |