make new-resizable on growable sequences return a growable of the same type

db4
Joe Groff 2009-10-22 18:55:00 -05:00
parent e31ed3eda4
commit cdd0e5774e
4 changed files with 8 additions and 2 deletions

View File

@ -24,6 +24,8 @@ M: V new-sequence drop [ <A> ] [ >fixnum ] bi V boa ; inline
M: A new-resizable drop <V> ; inline
M: V new-resizable drop <V> ; inline
M: V equal? over V instance? [ sequence= ] [ 2drop f ] if ;
: >V ( seq -- vector ) V new clone-like ; inline

View File

@ -43,4 +43,6 @@ M: byte-array like
M: byte-array new-resizable drop <byte-vector> ; inline
M: byte-vector new-resizable drop <byte-vector> ; inline
INSTANCE: byte-vector growable

View File

@ -66,4 +66,6 @@ M: growable shorten ( n seq -- )
2dup (>>length)
] when 2drop ; inline
M: growable new-resizable new-sequence 0 over set-length ; inline
INSTANCE: growable sequence

View File

@ -23,13 +23,13 @@ M: sbuf like
dup string? [ dup length sbuf boa ] [ >sbuf ] if
] unless ; inline
M: sbuf new-resizable drop <sbuf> ; inline
M: sbuf equal?
over sbuf? [ sequence= ] [ 2drop f ] if ;
M: string new-resizable drop <sbuf> ; inline
M: sbuf new-resizable drop <sbuf> ; inline
M: string like
#! If we have a string, we're done.
#! If we have an sbuf, and it's at full capacity, we're done.