]> gitweb.factorcode.org Git - factor.git/commitdiff
splitting: faster split-when.
authorJohn Benediktsson <mrjbq7@gmail.com>
Tue, 23 Mar 2021 16:08:37 +0000 (09:08 -0700)
committerJohn Benediktsson <mrjbq7@gmail.com>
Tue, 23 Mar 2021 16:08:37 +0000 (09:08 -0700)
The old way would accumulate in a vector and then add the last item on
by copying to a new array.

The new way accumulates in a vector including the last item and then
returns an array.

core/splitting/splitting.factor

index 6b83ea79e065193308ea7963e8b15038d1177245..464d1a3fc932a0abec4ca08a353b5f1e828734e0 100644 (file)
@@ -78,10 +78,10 @@ PRIVATE>
     [ 0 ] 3dip pick [
         swap curry [ keep 1 + swap ] curry [
             [ find-from drop dup ] 2curry [ keep -rot ] curry
-        ] dip produce nip
+        ] dip V{ } produce-as nip
     ] 2keep swap [
         [ length swapd ] keep
-    ] dip 2curry call suffix ; inline
+    ] dip 2curry call suffix! { } like ; inline
 
 PRIVATE>