marginally faster nappend
parent
3366640fb1
commit
13df2fe3e8
|
@ -65,7 +65,6 @@
|
||||||
- intrinsic char-slot set-char-slot integer-slot set-integer-slot
|
- intrinsic char-slot set-char-slot integer-slot set-integer-slot
|
||||||
- [ [ dup call ] dup call ] infer hangs
|
- [ [ dup call ] dup call ] infer hangs
|
||||||
- declarations
|
- declarations
|
||||||
- optimize away arithmetic dispatch
|
|
||||||
- the invalid recursion form case needs to be fixed, for inlines too
|
- the invalid recursion form case needs to be fixed, for inlines too
|
||||||
- #jump-f #jump-f-label
|
- #jump-f #jump-f-label
|
||||||
- re-introduce #target-label => #target optimization
|
- re-introduce #target-label => #target optimization
|
||||||
|
@ -75,8 +74,6 @@
|
||||||
+ sequences
|
+ sequences
|
||||||
|
|
||||||
- array sort
|
- array sort
|
||||||
- nappend: instead of using push, enlarge the sequence with set-length
|
|
||||||
then add set the elements with set-nth
|
|
||||||
- specialized arrays
|
- specialized arrays
|
||||||
|
|
||||||
+ kernel:
|
+ kernel:
|
||||||
|
|
|
@ -112,9 +112,13 @@ M: object >list ( seq -- list ) dup length 0 rot (>list) ;
|
||||||
: remove ( obj list -- list ) [ = not ] subset-with ;
|
: remove ( obj list -- list ) [ = not ] subset-with ;
|
||||||
: remq ( obj list -- list ) [ eq? not ] subset-with ;
|
: remq ( obj list -- list ) [ eq? not ] subset-with ;
|
||||||
|
|
||||||
: nappend ( s1 s2 -- )
|
: copy-into ( start to from -- )
|
||||||
#! Destructively append s2 to s1.
|
dup length [ >r pick r> + pick set-nth ] 2each 2drop ;
|
||||||
[ over push ] each drop ;
|
|
||||||
|
: nappend ( to from -- )
|
||||||
|
>r dup length swap r>
|
||||||
|
over length over length + pick set-length
|
||||||
|
copy-into ;
|
||||||
|
|
||||||
: append ( s1 s2 -- s1+s2 )
|
: append ( s1 s2 -- s1+s2 )
|
||||||
#! Outputs a new sequence of the same type as s1.
|
#! 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
|
dup pick index dup -1 = [ drop ] [ nip pick nth ] ifte
|
||||||
] map 2nip ;
|
] map 2nip ;
|
||||||
|
|
||||||
: copy-into ( to from -- )
|
|
||||||
dup length [ pick set-nth ] 2each drop ;
|
|
||||||
|
|
||||||
IN: kernel
|
IN: kernel
|
||||||
|
|
||||||
: depth ( -- n )
|
: depth ( -- n )
|
||||||
|
|
|
@ -148,9 +148,9 @@ M: mirror set-nth ( n mirror -- elt )
|
||||||
M: mirror length ( mirror -- len )
|
M: mirror length ( mirror -- len )
|
||||||
mirror-tuple array-capacity ;
|
mirror-tuple array-capacity ;
|
||||||
|
|
||||||
: literal-tuple ( list -- tuple )
|
: literal-tuple ( seq -- tuple )
|
||||||
dup first "tuple-size" word-prop <tuple>
|
dup first "tuple-size" word-prop <tuple>
|
||||||
[ <mirror> swap copy-into ] keep ;
|
[ <mirror> 0 swap rot copy-into ] keep ;
|
||||||
|
|
||||||
: clone-tuple ( tuple -- tuple )
|
: clone-tuple ( tuple -- tuple )
|
||||||
#! Make a shallow copy of a tuple, without cloning its
|
#! Make a shallow copy of a tuple, without cloning its
|
||||||
|
|
Loading…
Reference in New Issue