From: Jean-Christophe Beaupré Date: Sat, 20 Dec 2014 21:00:36 +0000 (-0500) Subject: stream: Optimize `StringIStream.read_all` X-Git-Tag: v0.7.1~38^2~11 X-Git-Url: http://nitlanguage.org stream: Optimize `StringIStream.read_all` Signed-off-by: Jean-Christophe Beaupré --- 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