From 2044dc24e19aa496cc7d7ac9f82e49af91a53208 Mon Sep 17 00:00:00 2001 From: Jean Privat Date: Thu, 16 Feb 2017 09:40:25 -0500 Subject: [PATCH] core/stream: StringWriter uses a Buffer internally Signed-off-by: Jean Privat --- lib/core/stream.nit | 14 ++++++++++---- 1 file changed, 10 insertions(+), 4 deletions(-) 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? -- 1.7.9.5