From: Slava Pestov Date: Tue, 9 Dec 2008 23:52:45 +0000 (-0600) Subject: Fix conflict X-Git-Tag: 0.94~2229^2~14^2~3 X-Git-Url: https://gitweb.factorcode.org/gitweb.cgi?p=factor.git;a=commitdiff_plain;h=eb79c6ab719e370ca2dd2acdf15efa6cbc1280a7 Fix conflict --- eb79c6ab719e370ca2dd2acdf15efa6cbc1280a7 diff --cc basis/byte-vectors/byte-vectors.factor index 0000000000,e24c808bbc..d146017db0 mode 000000,100644..100644 --- a/basis/byte-vectors/byte-vectors.factor +++ b/basis/byte-vectors/byte-vectors.factor @@@ -1,0 -1,51 +1,51 @@@ + ! Copyright (C) 2008 Slava Pestov. + ! See http://factorcode.org/license.txt for BSD license. + USING: arrays kernel kernel.private math sequences + sequences.private growable byte-arrays accessors parser + prettyprint.custom ; + IN: byte-vectors + + TUPLE: byte-vector + { underlying byte-array } + { length array-capacity } ; + + : ( n -- byte-vector ) - 0 byte-vector boa ; inline ++ (byte-array) 0 byte-vector boa ; inline + + : >byte-vector ( seq -- byte-vector ) + T{ byte-vector f B{ } 0 } clone-like ; + + M: byte-vector like + drop dup byte-vector? [ + dup byte-array? + [ dup length byte-vector boa ] [ >byte-vector ] if + ] unless ; + + M: byte-vector new-sequence - drop [ ] [ >fixnum ] bi byte-vector boa ; ++ drop [ (byte-array) ] [ >fixnum ] bi byte-vector boa ; + + M: byte-vector equal? + over byte-vector? [ sequence= ] [ 2drop f ] if ; + + M: byte-array like + #! If we have an byte-array, we're done. + #! If we have a byte-vector, and it's at full capacity, + #! we're done. Otherwise, call resize-byte-array, which is a + #! relatively fast primitive. + drop dup byte-array? [ + dup byte-vector? [ + [ length ] [ underlying>> ] bi + 2dup length eq? + [ nip ] [ resize-byte-array ] if + ] [ >byte-array ] if + ] unless ; + + M: byte-array new-resizable drop ; + + : BV{ \ } [ >byte-vector ] parse-literal ; parsing + + M: byte-vector pprint* pprint-object ; + M: byte-vector pprint-delims drop \ BV{ \ } ; + M: byte-vector >pprint-sequence ; + + INSTANCE: byte-vector growable diff --cc vm/types.h index d8d69dc541,ba8d9689fe..5850489a4c --- a/vm/types.h +++ b/vm/types.h @@@ -116,19 -116,17 +116,19 @@@ void primitive_tuple(void) void primitive_tuple_boa(void); void primitive_tuple_layout(void); void primitive_byte_array(void); +void primitive_uninitialized_byte_array(void); void primitive_clone(void); - F_ARRAY *reallot_array(F_ARRAY* array, CELL capacity, CELL fill); + F_ARRAY *reallot_array(F_ARRAY* array, CELL capacity); F_BYTE_ARRAY *reallot_byte_array(F_BYTE_ARRAY *array, CELL capacity); void primitive_resize_array(void); void primitive_resize_byte_array(void); F_STRING* allot_string_internal(CELL capacity); F_STRING* allot_string(CELL capacity, CELL fill); +void primitive_uninitialized_string(void); void primitive_string(void); - F_STRING *reallot_string(F_STRING *string, CELL capacity, CELL fill); + F_STRING *reallot_string(F_STRING *string, CELL capacity); void primitive_resize_string(void); F_STRING *memory_to_char_string(const char *string, CELL length);