combinators.short-circuit: speed up in non-optimized code

db4
Slava Pestov 2009-07-18 03:33:45 -05:00
parent 343151fd62
commit 60f4f4c16e
2 changed files with 41 additions and 8 deletions

View 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? ;

View File

@ -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 ]