io.streams.byte-array.fast: push-all is faster for byte-array.

clean-macosx-x86-32
John Benediktsson 2019-05-19 18:47:34 -07:00
parent 86046dcbf7
commit d150e5cfe2
1 changed files with 9 additions and 4 deletions

View 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 ;