]> gitweb.factorcode.org Git - factor.git/commitdiff
io.buffers, io.ports: trim some dispatch
authorJoe Groff <arcata@gmail.com>
Wed, 9 Nov 2011 21:31:02 +0000 (13:31 -0800)
committerJoe Groff <arcata@gmail.com>
Wed, 9 Nov 2011 21:31:02 +0000 (13:31 -0800)
For #376. Still some work to do.

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

index 73b982705bca8cf39a63a906021a4947f715d351..2dc11f39cd44d8ef5d8a9fff85b631de25b7142b 100644 (file)
@@ -14,12 +14,12 @@ TUPLE: buffer
 disposed ;
 
 : <buffer> ( n -- buffer )
-    dup malloc 0 0 f buffer boa ;
+    dup malloc 0 0 f buffer boa ; inline
 
-M: buffer dispose* ptr>> free ;
+M: buffer dispose* ptr>> free ; inline
 
 : buffer-reset ( n buffer -- )
-    swap >>fill 0 >>pos drop ;
+    swap >>fill 0 >>pos drop ; inline
 
 : buffer-capacity ( buffer -- n )
     [ size>> ] [ fill>> ] bi - >fixnum ; inline
index b255834dc0f742e7567e4a06ce56431773ce56aa..0daedfd4366587af8e6447aee151f886840a945e 100644 (file)
@@ -34,7 +34,7 @@ INSTANCE: input-port input-stream
 M: input-port stream-element-type drop +byte+ ; inline
 
 : <input-port> ( handle -- input-port )
-    input-port <buffered-port> ;
+    input-port <buffered-port> ; inline
 
 HOOK: (wait-to-read) io-backend ( port -- )
 
@@ -54,6 +54,8 @@ M: input-port stream-read1
         [ 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
 
@@ -61,6 +63,10 @@ M: input-port stream-read-partial-unsafe ( n dst port -- count )
     [ swap ] dip prepare-read read-step
     [ swap [ memcpy ] keep ] [ 2drop 0 ] if* ;
 
+HINTS: M\ input-port stream-read-unsafe
+    { fixnum byte-array input-port }
+    { fixnum string input-port } ;
+
 :: read-loop ( n-remaining n-read port dst -- n-total )
     n-remaining 0 > [
         n-remaining port read-step :> ( n-buffered ptr )
@@ -86,6 +92,10 @@ M:: input-port stream-read-unsafe ( n dst port -- count )
         ] if
     ] [ 0 ] if ;
 
+HINTS: M\ input-port stream-read-unsafe
+    { fixnum byte-array input-port }
+    { fixnum string input-port } ;
+
 : read-until-step ( separators port -- string/f separator/f )
     dup wait-to-read [ 2drop f f ] [ buffer>> buffer-until ] if ;