From: Jean Privat Date: Thu, 16 Feb 2017 14:40:25 +0000 (-0500) Subject: core/stream: StringWriter uses a Buffer internally X-Git-Url: http://nitlanguage.org core/stream: StringWriter uses a Buffer internally Signed-off-by: Jean Privat --- diff --git a/lib/core/stream.nit b/lib/core/stream.nit index 217e9c8..6fbc63c 100644 --- a/lib/core/stream.nit +++ b/lib/core/stream.nit @@ -668,18 +668,24 @@ end class StringWriter super Writer - private var content = new Array[String] - redef fun to_s do return content.plain_to_s + private var content = new Buffer + redef fun to_s do return content.to_s redef fun is_writable do return not closed redef fun write_bytes(b) do - content.add(b.to_s) + content.append(b.to_s) end redef fun write(str) do assert not closed - content.add(str.to_s) + content.append(str) + end + + redef fun write_char(c) + do + assert not closed + content.add(c) end # Is the stream closed?