From bbac97129e3425bfbea7de1983e991ed587d5ae5 Mon Sep 17 00:00:00 2001 From: Robby Findler Date: Fri, 22 Apr 2016 14:45:55 -0500 Subject: [PATCH] avoid an extra call to the contract-specific method for checking stronger Before this commit, when contract-stronger? is called, it would not be able to return #f until it calls the contract-specific stronger method twice --- racket/collects/racket/contract/private/prop.rkt | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/racket/collects/racket/contract/private/prop.rkt b/racket/collects/racket/contract/private/prop.rkt index 6d72833995..a3c9dbbbe3 100644 --- a/racket/collects/racket/contract/private/prop.rkt +++ b/racket/collects/racket/contract/private/prop.rkt @@ -152,14 +152,18 @@ ((prop:recursive-contract-unroll b) b) b)))] [else - (let loop ([b b]) + ;; the 'later?' flag avoids checking + ;; (stronger? a b) in the first iteration, + ;; since it was checked in the "optimistically" + ;; branch above + (let loop ([b b] [later? #f]) (cond - [(stronger? a b) + [(and later? (stronger? a b)) #t] [(prop:orc-contract? b) (define sub-contracts ((prop:orc-contract-get-subcontracts b) b)) (for/or ([sub-contract (in-list sub-contracts)]) - (loop sub-contract))] + (loop sub-contract #t))] [else #f]))])]))