io.streams.sequence: minor refactor, minor speedup.

db4
John Benediktsson 2012-07-27 21:12:26 -07:00
parent 9920f1d2aa
commit 3c03803f21
1 changed files with 3 additions and 5 deletions

View File

@ -11,11 +11,8 @@ SLOT: i
: >sequence-stream< ( stream -- i underlying )
[ i>> ] [ underlying>> ] bi ; inline
: next ( stream -- )
[ 1 + ] change-i drop ; inline
: sequence-read1 ( stream -- elt/f )
[ >sequence-stream< ?nth ] [ next ] bi ; inline
dup >sequence-stream< dupd ?nth [ 1 + swap i<< ] dip ; inline
: (sequence-read-length) ( n buf stream -- buf count )
[ underlying>> length ] [ i>> ] bi - rot min ; inline
@ -39,7 +36,8 @@ SLOT: i
: sequence-read-until ( seps stream -- seq sep/f )
[ find-separator ] keep
[ [ (sequence-read-unsafe) ] (read-into-new) ] [ next ] bi swap ; inline
[ [ (sequence-read-unsafe) ] (read-into-new) ]
[ [ 1 + ] change-i drop ] bi swap ; inline
! Writers
M: growable dispose drop ;