io: more inlining.
parent
4a14bd407d
commit
68f8d5bc17
|
@ -29,7 +29,8 @@ GENERIC: stream-seek ( n seek-type stream -- )
|
|||
GENERIC: stream-seekable? ( stream -- ? )
|
||||
GENERIC: stream-length ( stream -- n/f )
|
||||
|
||||
: stream-print ( str stream -- ) [ stream-write ] [ stream-nl ] bi ;
|
||||
: stream-print ( str stream -- )
|
||||
[ stream-write ] [ stream-nl ] bi ; inline
|
||||
|
||||
! Default streams
|
||||
MIXIN: input-stream
|
||||
|
@ -158,7 +159,9 @@ ERROR: invalid-read-buffer buf stream ;
|
|||
input-stream get swap each-stream-line ; inline
|
||||
|
||||
: stream-lines ( stream -- seq )
|
||||
[ [ ] collector [ each-stream-line ] dip { } like ] with-disposal ;
|
||||
[
|
||||
[ ] collector [ each-stream-line ] dip { } like
|
||||
] with-disposal ; inline
|
||||
|
||||
: lines ( -- seq )
|
||||
input-stream get stream-lines ; inline
|
||||
|
@ -183,21 +186,24 @@ CONSTANT: each-block-size 65536
|
|||
dup rot [
|
||||
[ (new-sequence-for-stream) ]
|
||||
[ [ stream-read-unsafe ] curry keep resize ] bi
|
||||
] with-disposal ;
|
||||
] with-disposal ; inline
|
||||
|
||||
: (stream-contents-by-block) ( stream -- seq )
|
||||
[
|
||||
[ [ ] collector [ each-stream-block ] dip { } like ]
|
||||
[ stream-exemplar concat-as ] bi
|
||||
] with-disposal ;
|
||||
] with-disposal ; inline
|
||||
|
||||
: (stream-contents-by-length-or-block) ( stream -- seq )
|
||||
dup stream-length
|
||||
[ (stream-contents-by-length) ]
|
||||
[ (stream-contents-by-length) ]
|
||||
[ (stream-contents-by-block) ] if* ; inline
|
||||
|
||||
: (stream-contents-by-element) ( stream -- seq )
|
||||
[
|
||||
[ [ stream-read1 dup ] curry [ ] ]
|
||||
[ stream-exemplar produce-as nip ] bi
|
||||
] with-disposal ;
|
||||
] with-disposal ; inline
|
||||
|
||||
: contents ( -- seq )
|
||||
input-stream get stream-contents ; inline
|
||||
|
@ -227,9 +233,9 @@ CONSTANT: each-block-size 65536
|
|||
[ stream-exemplar ] bi produce-as swap finalize-read-until ; inline
|
||||
PRIVATE>
|
||||
|
||||
M: input-stream stream-read-unsafe rot 0 read-loop ;
|
||||
M: input-stream stream-read-unsafe rot 0 read-loop ; inline
|
||||
M: input-stream stream-read-partial-unsafe stream-read-unsafe ; inline
|
||||
M: input-stream stream-read-until read-until-loop ;
|
||||
M: input-stream stream-read-until read-until-loop ; inline
|
||||
M: input-stream stream-readln
|
||||
"\n" swap stream-read-until drop ; inline
|
||||
M: input-stream stream-contents (stream-contents-by-length-or-block) ; inline
|
||||
|
@ -253,4 +259,3 @@ M: f stream-write1 2drop ; inline
|
|||
M: f stream-write 2drop ; inline
|
||||
M: f stream-flush drop ; inline
|
||||
M: f stream-nl drop ; inline
|
||||
|
||||
|
|
|
@ -42,7 +42,7 @@ M: c-reader stream-read1 dup check-disposed handle>> fgetc ;
|
|||
dup pick member-eq? [ 2nip ] [ , read-until-loop ] if
|
||||
] [
|
||||
2nip
|
||||
] if ;
|
||||
] if ; inline recursive
|
||||
|
||||
M: c-reader stream-read-until
|
||||
dup check-disposed
|
||||
|
|
Loading…
Reference in New Issue