marginally faster nappend

cvs
Slava Pestov 2005-08-04 16:58:07 +00:00
parent 3366640fb1
commit 13df2fe3e8
3 changed files with 9 additions and 11 deletions

View File

@ -65,7 +65,6 @@
- intrinsic char-slot set-char-slot integer-slot set-integer-slot
- [ [ dup call ] dup call ] infer hangs
- declarations
- optimize away arithmetic dispatch
- the invalid recursion form case needs to be fixed, for inlines too
- #jump-f #jump-f-label
- re-introduce #target-label => #target optimization
@ -75,8 +74,6 @@
+ sequences
- array sort
- nappend: instead of using push, enlarge the sequence with set-length
then add set the elements with set-nth
- specialized arrays
+ kernel:

View File

@ -112,9 +112,13 @@ M: object >list ( seq -- list ) dup length 0 rot (>list) ;
: remove ( obj list -- list ) [ = not ] subset-with ;
: remq ( obj list -- list ) [ eq? not ] subset-with ;
: nappend ( s1 s2 -- )
#! Destructively append s2 to s1.
[ over push ] each drop ;
: copy-into ( start to from -- )
dup length [ >r pick r> + pick set-nth ] 2each 2drop ;
: nappend ( to from -- )
>r dup length swap r>
over length over length + pick set-length
copy-into ;
: append ( s1 s2 -- s1+s2 )
#! Outputs a new sequence of the same type as s1.
@ -223,9 +227,6 @@ M: object reverse ( seq -- seq ) [ <reversed> ] keep like ;
dup pick index dup -1 = [ drop ] [ nip pick nth ] ifte
] map 2nip ;
: copy-into ( to from -- )
dup length [ pick set-nth ] 2each drop ;
IN: kernel
: depth ( -- n )

View File

@ -148,9 +148,9 @@ M: mirror set-nth ( n mirror -- elt )
M: mirror length ( mirror -- len )
mirror-tuple array-capacity ;
: literal-tuple ( list -- tuple )
: literal-tuple ( seq -- tuple )
dup first "tuple-size" word-prop <tuple>
[ <mirror> swap copy-into ] keep ;
[ <mirror> 0 swap rot copy-into ] keep ;
: clone-tuple ( tuple -- tuple )
#! Make a shallow copy of a tuple, without cloning its