]> gitweb.factorcode.org Git - factor.git/commitdiff
io.ports: make read-step TYPED:
authorJoe Groff <arcata@gmail.com>
Wed, 9 Nov 2011 22:13:41 +0000 (14:13 -0800)
committerJoe Groff <arcata@gmail.com>
Wed, 9 Nov 2011 22:13:41 +0000 (14:13 -0800)
Eliminates more dispatch. For #376.

basis/io/buffers/buffers.factor
basis/io/ports/ports.factor

index 2dc11f39cd44d8ef5d8a9fff85b631de25b7142b..b3001a518453a343fd3a71488c1743475c093fc2 100644 (file)
@@ -39,7 +39,7 @@ M: buffer dispose* ptr>> free ; inline
     [ buffer-peek ] [ 1 swap buffer-consume ] bi ; inline
 
 : buffer-length ( buffer -- n )
-    [ fill>> ] [ pos>> ] bi - ; inline
+    [ fill>> ] [ pos>> ] bi - >fixnum ; inline
 
 : buffer@ ( buffer -- alien )
     [ pos>> ] [ ptr>> ] bi <displaced-alien> ; inline
index 0daedfd4366587af8e6447aee151f886840a945e..eaae1e40a9e815d54a0031fd28260bea95fef5f9 100644 (file)
@@ -7,7 +7,7 @@ io.buffers io.encodings io.encodings.ascii io.encodings.binary
 io.encodings.private io.encodings.utf8 io.timeouts kernel libc
 locals math math.order namespaces sequences specialized-arrays
 specialized-arrays.instances.alien.c-types.uchar splitting
-strings summary system ;
+strings summary system typed ;
 IN: io.ports
 
 SYMBOL: default-buffer-size
@@ -47,15 +47,13 @@ M: input-port stream-read1
     dup check-disposed
     dup wait-to-read [ drop f ] [ buffer>> buffer-pop ] if ; inline
 
-: read-step ( count port -- count/f ptr/f )
+TYPED: read-step ( count: fixnum port: input-port -- count: fixnum ptr/f: c-ptr )
     {
-        { [ over 0 = ] [ 2drop f f ] }
-        { [ dup wait-to-read ] [ 2drop f f ] }
+        { [ over 0 = ] [ 2drop 0 f ] }
+        { [ dup wait-to-read ] [ 2drop 0 f ] }
         [ buffer>> buffer-read-unsafe ]
     } cond ;
 
-HINTS: read-step { fixnum input-port } ;
-
 : prepare-read ( count stream -- count stream )
     dup check-disposed [ 0 max >fixnum ] dip ; inline