sequences.extras: bounds-check in rotate! and do exchange-unsafe.

db4
John Benediktsson 2012-07-14 15:12:18 -07:00
parent bfb6bdd891
commit 6dc49d6014
1 changed files with 3 additions and 3 deletions

View File

@ -119,9 +119,9 @@ IN: sequences.extras
cut prepend ; cut prepend ;
:: rotate! ( seq n -- ) :: rotate! ( seq n -- )
seq length :> end n seq bounds-check length :> end
n 0 n [ 2dup = ] [ 0 n [ 2dup = ] [
[ seq exchange ] [ [ 1 + ] bi@ ] 2bi [ seq exchange-unsafe ] [ [ 1 + ] bi@ ] 2bi
dup end = [ drop over ] when dup end = [ drop over ] when
2over = [ -rot nip over ] when 2over = [ -rot nip over ] when
] until 3drop ; ] until 3drop ;