]> gitweb.factorcode.org Git - factor.git/commitdiff
using if-zero in more places.
authorJohn Benediktsson <mrjbq7@gmail.com>
Mon, 16 Jul 2012 22:45:21 +0000 (15:45 -0700)
committerJohn Benediktsson <mrjbq7@gmail.com>
Mon, 16 Jul 2012 22:45:21 +0000 (15:45 -0700)
basis/io/sockets/secure/unix/unix.factor
basis/peg/parsers/parsers.factor
basis/prettyprint/sections/sections.factor
basis/regexp/ast/ast.factor
extra/math/continued-fractions/continued-fractions.factor
extra/math/floating-point/floating-point.factor

index 4fe3b357212025ae18e8761a82d2af8437adaafc..0fb4a44dc5e4313751ed05ce10671d2407f0d666 100644 (file)
@@ -165,7 +165,7 @@ M: secure (accept)
         { SSL_ERROR_NONE [ 2drop f ] }
         { SSL_ERROR_WANT_READ [ 2drop +input+ ] }
         { SSL_ERROR_WANT_WRITE [ 2drop +output+ ] }
-        { SSL_ERROR_SYSCALL [ dup zero? [ 2drop f ] [ syscall-error ] if ] }
+        { SSL_ERROR_SYSCALL [ [ drop f ] [ syscall-error ] if-zero ] }
         { SSL_ERROR_SSL [ (ssl-error) ] }
     } case ;
 
index c8a8080f38f4ac9df3ded6272bd4f30093913ca3..5d483df6978ed9d790386646aa593d81634c4ee8 100644 (file)
@@ -48,11 +48,11 @@ PRIVATE>
   swap <repetition> seq ;
 
 : at-most-n ( parser n -- parser' )
-  dup zero? [
-    2drop epsilon
+  [
+    drop epsilon
   ] [
     [ exactly-n ] [ 1 - at-most-n ] 2bi 2choice
-  ] if ;
+  ] if-zero ;
 
 : at-least-n ( parser n -- parser' )
   dupd exactly-n swap repeat0 2seq
index c23daaa6c543ff1376cd2f9770c682a69ca59621..e9aae02c332cddaf69a9729800f6f53ba99acdc8 100644 (file)
@@ -59,8 +59,8 @@ M: maybe vocabulary-name
     ] if ;
 
 : text-fits? ( len -- ? )
-    margin get dup zero?
-    [ 2drop t ] [ [ pprinter get indent>> + ] dip <= ] if ;
+    margin get
+    [ drop t ] [ [ pprinter get indent>> + ] dip <= ] if-zero ;
 
 ! break only if position margin 2 / >
 SYMBOL: soft
index 90ab3342f2ea0eda65f26eae9184f126ebefb4d8..91ad42dd7e18cf7d372678aef9a463aeea7da8f2 100644 (file)
@@ -54,10 +54,9 @@ M: at-least <times>
     n>> swap [ repetition ] [ <star> ] bi 2array <concatenation> ;
 
 : to-times ( term n -- ast )
-    dup zero?
-    [ 2drop epsilon ]
+    [ drop epsilon ]
     [ dupd 1 - to-times 2array <concatenation> <maybe> ]
-    if ;
+    if-zero ;
 
 M: from-to <times>
     [ n>> swap repetition ]
index 26454a3e90e268466409245c1805a7db8e466816..84440b410a1920c54a48b0905544893ef16f4d47 100644 (file)
@@ -5,18 +5,20 @@ IN: math.continued-fractions
 
 <PRIVATE
 
-: split-float ( f -- d i ) dup >integer [ - ] keep ;
+: split-float ( f -- d i )
+    dup >integer [ - ] keep ;
 
-: closest ( seq -- newseq ) unclip-last round >integer suffix ;
+: closest ( seq -- newseq )
+    unclip-last round >integer suffix ;
 
 PRIVATE>
 
 : next-approx ( seq -- )
     dup [ pop split-float ] [ push ] bi
-    dup zero? [ 2drop ] [ recip swap push ] if ;
+    [ drop ] [ recip swap push ] if-zero ;
 
 : >ratio ( seq -- a/b )
-    closest reverse unclip-slice [ swap recip + ] reduce ;
+    closest reverse! unclip-slice [ swap recip + ] reduce ;
 
 : approx ( epsilon float -- a/b )
     dup 1vector
index fb9b258038abca54f65095104f60efb1ba03b133..66dc6440e3a35cbe117d0c9d41d7a627bb4b28a1 100644 (file)
@@ -53,5 +53,5 @@ IN: math.floating-point
     [ (double-sign) zero? 1 -1 ? ]
     [ (double-mantissa-bits) 52 2^ / ]
     [ (double-exponent-bits) ] tri
-    dup zero? [ 1 + ] [ [ 1 + ] dip ] if 1023 - 2 swap ^ * * ;
+    [ 1 ] [ [ 1 + ] dip ] if-zero 1023 - 2 swap ^ * * ;