]> gitweb.factorcode.org Git - factor.git/commitdiff
sorting: circularity if we use cleave in sorting
authorDoug Coleman <doug.coleman@gmail.com>
Mon, 8 Aug 2022 00:41:50 +0000 (19:41 -0500)
committerDoug Coleman <doug.coleman@gmail.com>
Sun, 26 Feb 2023 23:11:03 +0000 (17:11 -0600)
core/sorting/sorting.factor

index 398fbd79cfadfaf940ada9f0b80f63b0288c0808..969a80bc798dcdf0389015f656673ac4f8b6b99d 100644 (file)
@@ -1,6 +1,6 @@
 ! Copyright (C) 2005, 2009 Slava Pestov.
 ! See http://factorcode.org/license.txt for BSD license.
-USING: accessors arrays assocs combinators growable.private
+USING: accessors arrays assocs growable.private
 hashtables kernel kernel.private math math.order math.private
 sequences sequences.private vectors ;
 IN: sorting
@@ -33,20 +33,18 @@ TUPLE: merge-state
 : r-done? ( merge -- ? ) [ from2>> ] [ to2>> ] bi eq? ; inline
 
 : dump-l ( merge -- )
-    {
-        [ accum>> ]
-        [ [ to1>> ] [ from1>> fixnum-fast ] [ accum>> length integer>fixnum-strict ] tri [ fixnum+fast >>length ] 2keep ]
-        [ seq>> ]
-        [ from1>> roll dupd fixnum+fast ]
-    } cleave seq-copy-loop drop ; inline
+    [ accum>> ] keep
+    [ [ to1>> ] [ from1>> fixnum-fast ] [ accum>> length integer>fixnum-strict ] tri [ fixnum+fast >>length ] 2keep ]
+    [ seq>> ]
+    [ from1>> roll dupd fixnum+fast ] tri
+    seq-copy-loop drop ; inline
 
 : dump-r ( merge -- )
-    {
-        [ accum>> ]
-        [ [ to2>> ] [ from2>> fixnum-fast ] [ accum>> length integer>fixnum-strict ] tri [ fixnum+fast >>length ] 2keep ]
-        [ seq>> ]
-        [ from2>> roll dupd fixnum+fast ]
-    } cleave seq-copy-loop drop ; inline
+    [ accum>> ] keep
+    [ [ to2>> ] [ from2>> fixnum-fast ] [ accum>> length integer>fixnum-strict ] tri [ fixnum+fast >>length ] 2keep ]
+    [ seq>> ]
+    [ from2>> roll dupd fixnum+fast ] tri
+    seq-copy-loop drop ; inline
 
 : l-next ( merge -- )
     [ l-elt ] [ [ 1 + ] change-from1 accum>> ] bi push-unsafe ; inline