From bdab665e36fce7f3cfa34e0ff56950a0362aed86 Mon Sep 17 00:00:00 2001 From: Tony Garnock-Jones Date: Mon, 2 Jun 2014 14:12:45 -0400 Subject: [PATCH] Avoid laborious projection if all we're doing is capturing the whole thing anyway. --- minimart/gestalt.rkt | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/minimart/gestalt.rkt b/minimart/gestalt.rkt index ff5d736..09b607f 100644 --- a/minimart/gestalt.rkt +++ b/minimart/gestalt.rkt @@ -92,12 +92,16 @@ (define (compile-gestalt-projection . specs) (compile-gestalt-projection* specs)) +(define capture-everything-projection (compile-gestalt-projection (?!))) + ;; Gestalt × Natural × Natural × Boolean × CompiledSpec → Matcher (define (gestalt-project g metalevel level get-advertisements? capture-spec) (define levels (safe-list-ref (gestalt-metalevels g) metalevel (lambda () empty-metalevel))) (define matcher ((if get-advertisements? cdr car) (safe-list-ref levels level (lambda () empty-level)))) - (matcher-project matcher capture-spec)) + (if (equal? capture-spec capture-everything-projection) + matcher + (matcher-project matcher capture-spec))) (define (drop-gestalt g) (gestalt (safe-cdr (gestalt-metalevels g))))