From: John Benediktsson Date: Fri, 13 Dec 2019 22:38:26 +0000 (-0800) Subject: core/basis/extra: using while* in a few places. X-Git-Tag: 0.99~3621 X-Git-Url: https://gitweb.factorcode.org/gitweb.cgi?p=factor.git;a=commitdiff_plain;h=77b13fbdc206dd4cfa171a93398d4375d4b83e7e core/basis/extra: using while* in a few places. --- diff --git a/basis/io/encodings/string/string.factor b/basis/io/encodings/string/string.factor index e6f278e5b3..f58fb98903 100644 --- a/basis/io/encodings/string/string.factor +++ b/basis/io/encodings/string/string.factor @@ -13,7 +13,7 @@ IN: io.encodings.string ] [ byte-array encoding :> reader byte-array length encoding guess-decoded-length :> buf - [ reader stream-read1 dup ] [ buf push ] while drop + [ reader stream-read1 ] [ buf push ] while* buf "" like ] if ] if ; inline diff --git a/basis/json/reader/reader.factor b/basis/json/reader/reader.factor index 39e932c102..7d223c0623 100644 --- a/basis/json/reader/reader.factor +++ b/basis/json/reader/reader.factor @@ -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. diff --git a/core/io/io.factor b/core/io/io.factor index d1e345a2a8..9d20471b29 100644 --- a/core/io/io.factor +++ b/core/io/io.factor @@ -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 - 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 -- ) diff --git a/extra/cuesheet/cuesheet.factor b/extra/cuesheet/cuesheet.factor index 8f5b86a599..77eaa721dd 100644 --- a/extra/cuesheet/cuesheet.factor +++ b/extra/cuesheet/cuesheet.factor @@ -127,7 +127,7 @@ ERROR: unknown-syntax syntax ; PRIVATE> : read-cuesheet ( -- cuesheet ) - [ readln dup ] [ parse-line ] while drop ; + [ readln ] [ parse-line ] while* ; : file>cuesheet ( path -- cuesheet ) utf8 [ read-cuesheet ] with-file-reader ; diff --git a/extra/html/entities/entities.factor b/extra/html/entities/entities.factor index 1baab98029..9902326f0b 100644 --- a/extra/html/entities/entities.factor +++ b/extra/html/entities/entities.factor @@ -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 ; 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? ) diff --git a/extra/tokyo/assoc-functor/assoc-functor.factor b/extra/tokyo/assoc-functor/assoc-functor.factor index 1c4ff1b88a..d9b9392b08 100644 --- a/extra/tokyo/assoc-functor/assoc-functor.factor +++ b/extra/tokyo/assoc-functor/assoc-functor.factor @@ -37,10 +37,10 @@ M: TYPE assoc-size handle>> DBRNUM ; : DBKEYS ( db -- keys ) [ assoc-size ] [ handle>> ] bi dup DBITERINIT drop 0 int - [ 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 ; diff --git a/extra/trees/trees.factor b/extra/trees/trees.factor index b9b00e2b47..b43da272dd 100644 --- a/extra/trees/trees.factor +++ b/extra/trees/trees.factor @@ -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 ;