]> gitweb.factorcode.org Git - factor.git/commitdiff
combinators.short-circuit: speed up in non-optimized code
authorSlava Pestov <slava@slava-pestovs-macbook-pro.local>
Sat, 18 Jul 2009 08:33:45 +0000 (03:33 -0500)
committerSlava Pestov <slava@slava-pestovs-macbook-pro.local>
Sat, 18 Jul 2009 08:33:45 +0000 (03:33 -0500)
basis/combinators/short-circuit/short-circuit.factor
basis/stack-checker/transforms/transforms.factor

index d8bab4dd347b47a8cca0e4592b004c90fc679c19..aff25efa96b7111bf82c868e653992b7528b9f27 100644 (file)
@@ -12,10 +12,10 @@ MACRO:: n&& ( quots n -- quot )
     n '[ _ nnip ] suffix 1array
     [ cond ] 3append ;
 
-MACRO: 0&& ( quots -- quot ) '[ _ 0 n&& ] ;
-MACRO: 1&& ( quots -- quot ) '[ _ 1 n&& ] ;
-MACRO: 2&& ( quots -- quot ) '[ _ 2 n&& ] ;
-MACRO: 3&& ( quots -- quot ) '[ _ 3 n&& ] ;
+: 0&& ( quots -- ? ) [ call ] all? ;
+: 1&& ( obj quots -- ? ) [ call ] with all? ;
+: 2&& ( obj quots -- ? ) [ call ] with with all? ;
+: 3&& ( obj quots -- ? ) [ call ] with with with all? ;
 
 MACRO:: n|| ( quots n -- quot )
     [ f ] quots [| q |
@@ -27,7 +27,8 @@ MACRO:: n|| ( quots n -- quot )
     n '[ drop _ ndrop t ] [ f ] 2array suffix 1array
     [ cond ] 3append ;
 
-MACRO: 0|| ( quots -- quot ) '[ _ 0 n|| ] ;
-MACRO: 1|| ( quots -- quot ) '[ _ 1 n|| ] ;
-MACRO: 2|| ( quots -- quot ) '[ _ 2 n|| ] ;
-MACRO: 3|| ( quots -- quot ) '[ _ 3 n|| ] ;
+: 0|| ( quots -- ? ) [ call ] any? ;
+: 1|| ( obj quots -- ? ) [ call ] with any? ;
+: 2|| ( obj quots -- ? ) [ call ] with with any? ;
+: 3|| ( obj quots -- ? ) [ call ] with with with any? ;
+
index 056eda8b6120d0edc86ae4e1a95414e965b77857..11534c58f9f215bd356f85a88e26e7a0fd7bf138 100755 (executable)
@@ -83,6 +83,38 @@ IN: stack-checker.transforms
 
 \ spread t "no-compile" set-word-prop
 
+\ 0&& [ '[ _ 0 n&& ] ] 1 define-transform
+
+\ 0&& t "no-compile" set-word-prop
+
+\ 1&& [ '[ _ 1 n&& ] ] 1 define-transform
+
+\ 1&& t "no-compile" set-word-prop
+
+\ 2&& [ '[ _ 2 n&& ] ] 1 define-transform
+
+\ 2&& t "no-compile" set-word-prop
+
+\ 3&& [ '[ _ 3 n&& ] ] 1 define-transform
+
+\ 3&& t "no-compile" set-word-prop
+
+\ 0|| [ '[ _ 0 n|| ] ] 1 define-transform
+
+\ 0|| t "no-compile" set-word-prop
+
+\ 1|| [ '[ _ 1 n|| ] ] 1 define-transform
+
+\ 1|| t "no-compile" set-word-prop
+
+\ 2|| [ '[ _ 2 n|| ] ] 1 define-transform
+
+\ 2|| t "no-compile" set-word-prop
+
+\ 3|| [ '[ _ 3 n|| ] ] 1 define-transform
+
+\ 3|| t "no-compile" set-word-prop
+
 \ (call-next-method) [
     [
         [ "method-class" word-prop ]