]> gitweb.factorcode.org Git - factor.git/commitdiff
io.encodings: stream-contents method for decoder
authorJoe Groff <arcata@gmail.com>
Sat, 15 Oct 2011 01:08:27 +0000 (18:08 -0700)
committerJoe Groff <arcata@gmail.com>
Tue, 18 Oct 2011 04:23:07 +0000 (21:23 -0700)
stream-contents on decoder is much faster implemented using a read1 loop than with the default implementation.

core/io/encodings/encodings.factor

index 7de56589c8e1bf77384de0082b2d2cff7fa77960..be99b178d4d9132aa408a86bb44c3ce9bb892b5b 100644 (file)
@@ -91,7 +91,7 @@ M: decoder stream-read1 ( decoder -- ch )
         ] [ (finish-read) ] if*
     ] if ; inline recursive
 
-M: decoder stream-read-unsafe ( n buf decoder -- count )
+M: decoder stream-read-unsafe
     pick 0 = [ 3drop 0 ] [
         (read-first) [
             0 (store-read)
@@ -99,6 +99,9 @@ M: decoder stream-read-unsafe ( n buf decoder -- count )
         ] [ 2drop 2drop 0 ] if*
     ] if ; inline
 
+M: decoder stream-contents
+    (stream-contents-by-element) ;
+
 : line-ends/eof ( stream str -- str ) f like swap cr- ; inline
 
 : line-ends\r ( stream str -- str ) swap cr+ ; inline