]> gitweb.factorcode.org Git - factor.git/blob - basis/io/streams/byte-array/fast/fast.factor
9f74d0778b240067a747608d43e23b937c3f07f2
[factor.git] / basis / io / streams / byte-array / fast / fast.factor
1 ! Copyright (C) 2010 Slava Pestov.
2 ! See http://factorcode.org/license.txt for BSD license.
3 USING: alien byte-arrays byte-vectors io kernel libc math
4 sequences ;
5 IN: io.streams.byte-array.fast
6
7 ! This is split off from io.streams.byte-array because it uses
8 ! memcpy, which is a non-core word that only works after the
9 ! optimizing compiler has been loaded.
10
11 M: byte-vector stream-write
12     over byte-array? [
13         push-all ! faster than memcpy
14     ] [
15         2dup [ byte-length ] bi@
16         3dup + swap lengthen
17         [ tail-slice swap ] curry dip memcpy
18     ] if ;