From 325db2fe7b480814ad394b3bac9afc92c20a3059 Mon Sep 17 00:00:00 2001 From: =?utf8?q?Jean-Christophe=20Beaupr=C3=A9?= Date: Sat, 20 Dec 2014 16:00:36 -0500 Subject: [PATCH] stream: Optimize `StringIStream.read_all` MIME-Version: 1.0 Content-Type: text/plain; charset=utf8 Content-Transfer-Encoding: 8bit Signed-off-by: Jean-Christophe Beaupré --- lib/standard/stream.nit | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/lib/standard/stream.nit b/lib/standard/stream.nit index 46ad73c..ddc01fe 100644 --- a/lib/standard/stream.nit +++ b/lib/standard/stream.nit @@ -493,5 +493,12 @@ class StringIStream source = "" end + redef fun read_all do + var c = cursor + cursor = source.length + if c == 0 then return source + return source.substring_from(c) + end + redef fun eof do return cursor >= source.length end -- 1.7.9.5