factor/basis/io/streams/byte-array/fast/fast.factor

19 lines
573 B
Factor

! Copyright (C) 2010 Slava Pestov.
! See http://factorcode.org/license.txt for BSD license.
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
! memcpy, which is a non-core word that only works after the
! optimizing compiler has been loaded.
M: byte-vector stream-write
over byte-array? [
push-all ! faster than memcpy
] [
2dup [ byte-length ] bi@
3dup + swap lengthen
[ tail-slice swap ] curry dip memcpy
] if ;