]> gitweb.factorcode.org Git - factor.git/commitdiff
core/basis/extra: using while* in a few places.
authorJohn Benediktsson <mrjbq7@gmail.com>
Fri, 13 Dec 2019 22:38:26 +0000 (14:38 -0800)
committerJohn Benediktsson <mrjbq7@gmail.com>
Fri, 13 Dec 2019 22:38:26 +0000 (14:38 -0800)
basis/io/encodings/string/string.factor
basis/json/reader/reader.factor
core/io/io.factor
extra/audio/wav/wav.factor
extra/cuesheet/cuesheet.factor
extra/html/entities/entities.factor
extra/images/atlas/atlas.factor
extra/tokyo/assoc-functor/assoc-functor.factor
extra/trees/trees.factor

index e6f278e5b3711663adc7b97e458bc1c9a1d62916..f58fb9890319c66ee6314d2980657a1fbbd440b4 100644 (file)
@@ -13,7 +13,7 @@ IN: io.encodings.string
         ] [
             byte-array encoding <byte-reader> :> reader
             byte-array length encoding guess-decoded-length <sbuf> :> buf
-            [ reader stream-read1 dup ] [ buf push ] while drop
+            [ reader stream-read1 ] [ buf push ] while*
             buf "" like
         ] if
     ] if ; inline
index 39e932c1025f0a5c59ee6ab9343b39c596244102..7d223c062312957769bd225855292d4c13e1b1cb 100644 (file)
@@ -126,7 +126,7 @@ DEFER: (read-json-string)
     } case ;
 
 : json-read-input ( stream -- objects )
-    V{ } clone over '[ _ stream-read1 dup ] [ scan ] while drop nip ;
+    V{ } clone over '[ _ stream-read1 ] [ scan ] while* nip ;
 
 ! If there are no json objects, return an empty hashtable
 ! This happens for empty files.
index d1e345a2a8be4281f4e908f3cd4c227f7e51cfb7..9d20471b29ee0adf644f6cd1cd4e08771f175326 100644 (file)
@@ -103,9 +103,6 @@ SYMBOL: error-stream
 
 : bl ( -- ) output-stream get stream-bl ;
 
-: each-morsel ( ..a handler: ( ..a data -- ..b ) reader: ( ..b -- ..a data ) -- ..a )
-    [ dup ] compose swap while drop ; inline
-
 <PRIVATE
 
 : stream-exemplar ( stream -- exemplar )
@@ -156,7 +153,7 @@ ERROR: invalid-read-buffer buf stream ;
     input-stream get stream-read-partial-into ; inline
 
 : each-stream-line ( ... stream quot: ( ... line -- ... ) -- ... )
-    swap [ stream-readln ] curry each-morsel ; inline
+    [ [ stream-readln ] curry ] dip while* ; inline
 
 : each-line ( ... quot: ( ... line -- ... ) -- ... )
     input-stream get swap each-stream-line ; inline
@@ -172,15 +169,16 @@ ERROR: invalid-read-buffer buf stream ;
 CONSTANT: each-block-size 65536
 
 : (each-stream-block-slice) ( ... stream quot: ( ... block-slice -- ... ) block-size -- ... )
-    [ [ drop ] prepose swap ] dip
-    [ swap (new-sequence-for-stream) ] keepd
-    [ stream-read-partial-into ] 2curry each-morsel drop ; inline
+    -rot [
+        [ (new-sequence-for-stream) ] keep
+        [ stream-read-partial-into ] 2curry
+    ] dip while drop ; inline
 
 : each-stream-block-slice ( ... stream quot: ( ... block-slice -- ... ) -- ... )
     each-block-size (each-stream-block-slice) ; inline
 
 : (each-stream-block) ( ... stream quot: ( ... block -- ... ) block-size -- ... )
-    rot [ stream-read-partial ] 2curry each-morsel ; inline
+    -rot [ [ stream-read-partial ] 2curry ] dip while* ; inline
 
 : each-stream-block ( ... stream quot: ( ... block -- ... ) -- ... )
     each-block-size (each-stream-block) ; inline
index 8c94ce9767febc352c4c029b13eac619506f291f..fe062df9cf2fe8d54dca429530b854822dea59c9 100644 (file)
@@ -38,12 +38,12 @@ STRUCT: wav-data-chunk
 
 :: read-wav-chunks ( -- fmt data )
     f :> fmt! f :> data!
-    [ { [ fmt data and not ] [ read-chunk ] } 0&& dup ]
+    [ { [ fmt data and not ] [ read-chunk ] } 0&& ]
     [ {
         { [ dup FMT-MAGIC  wav-fmt-chunk  check-chunk ] [ wav-fmt-chunk  memory>struct fmt!  ] }
         { [ dup DATA-MAGIC wav-data-chunk check-chunk ] [ wav-data-chunk memory>struct data! ] }
         [ drop ]
-    } cond ] while drop
+    } cond ] while*
     fmt data 2dup and [ invalid-audio-file ] unless ;
 
 : verify-wav ( chunk -- )
index 8f5b86a599e8eff460a6981c86e706a67e7ca5f1..77eaa721ddea258620bed6beb233f2e11a185a9c 100644 (file)
@@ -127,7 +127,7 @@ ERROR: unknown-syntax syntax ;
 PRIVATE>
 
 : read-cuesheet ( -- cuesheet )
-    <cuesheet> [ readln dup ] [ parse-line ] while drop ;
+    <cuesheet> [ readln ] [ parse-line ] while* ;
 
 : file>cuesheet ( path -- cuesheet )
     utf8 [ read-cuesheet ] with-file-reader ;
index 1baab98029c716cc572c932f4af9acd6752ef1c5..9902326f0b328ba35d67cc96769c7e53578c6c98 100644 (file)
@@ -28,7 +28,7 @@ PRIVATE>
 
 : html-escape ( str -- newstr )
     [
-        [ dup next-escape dup ] [ escape, ] while 2drop ,
+        [ dup next-escape ] [ escape, ] while* drop ,
     ] { } make dup length 1 > [ concat ] [ first ] if ;
 
 <PRIVATE
index 7546ff8db9d4edb666c2db61d8348f74bda7e18b..84e9b90f3c07ed807f81f04cce26ef414b72c174 100644 (file)
@@ -47,7 +47,7 @@ ERROR: atlas-image-formats-dont-match images ;
 :: (pack-images) ( images atlas-width sort-quot -- placements )
     images sort-quot inv-sort-with [ f image-placement boa ] map :> image-placements
     0 :> @y!
-    [ image-placements atlas-width @y (pack-stripe) dup ] [ @y + @y! ] while drop
+    [ image-placements atlas-width @y (pack-stripe) ] [ @y + @y! ] while*
     image-placements ; inline
 
 : atlas-image-format ( image-placements -- component-order component-type upside-down? )
index 1c4ff1b88a65e981d01bbaadf2617d427bdc61e6..d9b9392b08fe2441636d7731f654a01cc26e056e 100644 (file)
@@ -37,10 +37,10 @@ M: TYPE assoc-size handle>> DBRNUM ;
 : DBKEYS ( db -- keys )
     [ assoc-size <vector> ] [ handle>> ] bi
     dup DBITERINIT drop 0 int <ref>
-    [ 2dup DBITERNEXT dup ] [
+    [ 2dup DBITERNEXT ] [
         [ memory>object ] [ tcfree ] bi
         reach push
-    ] while 3drop ;
+    ] while* 2drop ;
 
 M: TYPE >alist
     [ DBKEYS dup ] keep '[ dup _ at 2array ] map! drop ;
index b9b00e2b47a092c4420b07a68dd39d9cc933349c..b43da272dd3698ec38732400637acd66712eaaa2 100644 (file)
@@ -238,10 +238,10 @@ PRIVATE>
     [ root>> (nodepath-at) ] { } make ;
 
 : right-extremity ( node -- node' )
-    [ dup right>> dup ] [ nip ] while drop ;
+    [ dup right>> ] [ nip ] while* ;
 
 : left-extremity ( node -- node' )
-    [ dup left>> dup ] [ nip ] while drop ;
+    [ dup left>> ] [ nip ] while* ;
 
 : lower-node-in-child? ( key node -- ? )
     [ nip left>> ] [ key>> = ] 2bi and ;