]> gitweb.factorcode.org Git - factor.git/commitdiff
io.files: simplify set-file-lines, set-file-contents.
authorJohn Benediktsson <mrjbq7@gmail.com>
Wed, 31 May 2023 21:22:43 +0000 (14:22 -0700)
committerJohn Benediktsson <mrjbq7@gmail.com>
Wed, 31 May 2023 21:22:43 +0000 (14:22 -0700)
core/io/files/files.factor

index 519054f5cff14e0bef5b6e190bc9d2f42e32d5c9..893e8871b9b1675c7e951fcab3825cdeeb8cfe59 100644 (file)
@@ -57,15 +57,13 @@ HOOK: (file-appender) io-backend ( path -- stream )
     [ [ print ] each ] with-file-writer ;
 
 : change-file-lines ( ..a path encoding quot: ( ..a seq -- ..b seq' ) -- ..b )
-    [ [ file-lines ] dip call ]
-    [ drop set-file-lines ] 3bi ; inline
+    '[ file-lines @ ] [ set-file-lines ] 2bi ; inline
 
 : set-file-contents ( seq path encoding -- )
     [ write ] with-file-writer ;
 
 : change-file-contents ( ..a path encoding quot: ( ..a seq -- ..b seq' ) -- ..b )
-    [ [ file-contents ] dip call ]
-    [ drop set-file-contents ] 3bi ; inline
+    '[ file-contents @ ] [ set-file-contents ] 2bi ; inline
 
 : with-file-appender ( path encoding quot -- )
     [ <file-appender> ] dip with-output-stream ; inline