From 0b5bf0e912c3e9552578e8c6bafb99d3b266bff6 Mon Sep 17 00:00:00 2001 From: Joe Marshall Date: Tue, 2 Mar 2010 10:43:48 -0800 Subject: [PATCH] Slightly smarter expansion for EQ? #F. --- src/sf/usiexp.scm | 18 +++++++++++++----- 1 file changed, 13 insertions(+), 5 deletions(-) diff --git a/src/sf/usiexp.scm b/src/sf/usiexp.scm index c817de4f1..516203b3a 100644 --- a/src/sf/usiexp.scm +++ b/src/sf/usiexp.scm @@ -465,13 +465,21 @@ USA. (define (eq?-expansion expr operands block) (if (and (pair? operands) (pair? (cdr operands)) - (not (pair? (cddr operands)))) + (null? (cddr operands))) ;; Convert (eq? #f) and (eq? #f ) to (not ) ;; Conditional inversion will remove the call to not. - (cond ((constant-eq? (first operands) #f) - (make-combination expr block (ucode-primitive not) (cdr operands))) - ((constant-eq? (second operands) #f) - (make-combination expr block (ucode-primitive not) (list (car operands)))) + (cond ((expression/always-false? (first operands)) + (if (expression/effect-free? (first operands)) + (make-combination expr block (ucode-primitive not) (cdr operands)) + (sequence/make (and expr (object/scode expr)) + (list (first operands) + (make-combination #f block (ucode-primitive not) (cdr operands)))))) + ((expression/always-false? (second operands)) + (if (expression/effect-free? (second operands)) + (make-combination expr block (ucode-primitive not) (list (car operands))) + (sequence/make (and expr (object/scode expr)) + (list (second operands) + (make-combination #f block (ucode-primitive not) (list (car operands))))))) (else (make-combination expr block (ucode-primitive eq?) operands))) #f)) -- 2.25.1