]> gitweb.factorcode.org Git - factor.git/commitdiff
io.streams.byte-array.fast: push-all is faster for byte-array.
authorJohn Benediktsson <mrjbq7@gmail.com>
Mon, 20 May 2019 01:47:34 +0000 (18:47 -0700)
committerJohn Benediktsson <mrjbq7@gmail.com>
Mon, 20 May 2019 01:47:34 +0000 (18:47 -0700)
basis/io/streams/byte-array/fast/fast.factor

index 2948e2bc61dd2b0f1bc067f5e3df40414cb1d03a..9f74d0778b240067a747608d43e23b937c3f07f2 100644 (file)
@@ -1,6 +1,7 @@
 ! Copyright (C) 2010 Slava Pestov.
 ! See http://factorcode.org/license.txt for BSD license.
-USING: alien byte-vectors io kernel libc math sequences ;
+USING: alien byte-arrays byte-vectors io kernel libc math
+sequences ;
 IN: io.streams.byte-array.fast
 
 ! This is split off from io.streams.byte-array because it uses
@@ -8,6 +9,10 @@ IN: io.streams.byte-array.fast
 ! optimizing compiler has been loaded.
 
 M: byte-vector stream-write
-    [ dup byte-length tail-slice swap ]
-    [ [ [ byte-length ] bi@ + ] keep lengthen ] 2bi
-    dup byte-length memcpy ;
+    over byte-array? [
+        push-all ! faster than memcpy
+    ] [
+        2dup [ byte-length ] bi@
+        3dup + swap lengthen
+        [ tail-slice swap ] curry dip memcpy
+    ] if ;