Minor change to copy and subseq to improve type inference

db4
Slava Pestov 2008-09-12 08:18:57 -05:00
parent 54232f80ca
commit 91faff92de
1 changed files with 8 additions and 2 deletions

View File

@ -236,6 +236,10 @@ INSTANCE: repetition immutable-sequence
<PRIVATE <PRIVATE
: check-length ( n -- n )
#! Ricing.
dup integer? [ "length not an integer" throw ] unless ; inline
: ((copy)) ( dst i src j n -- dst i src j n ) : ((copy)) ( dst i src j n -- dst i src j n )
dup -roll [ dup -roll [
+ swap nth-unsafe -roll [ + swap nth-unsafe -roll [
@ -248,8 +252,9 @@ INSTANCE: repetition immutable-sequence
inline recursive inline recursive
: prepare-subseq ( from to seq -- dst i src j n ) : prepare-subseq ( from to seq -- dst i src j n )
#! The check-length call forces partial dispatch
[ >r swap - r> new-sequence dup 0 ] 3keep [ >r swap - r> new-sequence dup 0 ] 3keep
-rot drop roll length ; inline -rot drop roll length check-length ; inline
: check-copy ( src n dst -- ) : check-copy ( src n dst -- )
over 0 < [ bounds-error ] when over 0 < [ bounds-error ] when
@ -273,7 +278,8 @@ PRIVATE>
: but-last ( seq -- headseq ) 1 head* ; : but-last ( seq -- headseq ) 1 head* ;
: copy ( src i dst -- ) : copy ( src i dst -- )
pick length >r 3dup check-copy spin 0 r> #! The check-length call forces partial dispatch
pick length check-length >r 3dup check-copy spin 0 r>
(copy) drop ; inline (copy) drop ; inline
M: sequence clone-like M: sequence clone-like