]> gitweb.factorcode.org Git - factor.git/commitdiff
sequences.extras: bounds-check in rotate! and do exchange-unsafe.
authorJohn Benediktsson <mrjbq7@gmail.com>
Sat, 14 Jul 2012 22:12:18 +0000 (15:12 -0700)
committerJohn Benediktsson <mrjbq7@gmail.com>
Sat, 14 Jul 2012 22:12:18 +0000 (15:12 -0700)
extra/sequences/extras/extras.factor

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