From 505c52e85a99e3eb012cc597519238fc57f7871f Mon Sep 17 00:00:00 2001 From: Joe Marshall Date: Sat, 14 Jan 2012 11:33:16 -0800 Subject: [PATCH] Suppress redundant type checks in generated pattern matching code. --- src/compiler/base/pmlook.scm | 10 ++++++---- src/compiler/base/pmpars.scm | 6 ++++-- 2 files changed, 10 insertions(+), 6 deletions(-) diff --git a/src/compiler/base/pmlook.scm b/src/compiler/base/pmlook.scm index 6e1bf30f1..52c31d5d0 100644 --- a/src/compiler/base/pmlook.scm +++ b/src/compiler/base/pmlook.scm @@ -108,17 +108,19 @@ USA. (r-null? (close-syntax 'NULL? environment)) (r-pair? (close-syntax 'PAIR? environment)) (r-quote (close-syntax 'QUOTE environment))) - (let descend ((pattern pattern) + (let descend ((top-level #t) + (pattern pattern) (body `(,body ,@(pattern-variables pattern)))) (if (pair? pattern) (if (eq? (car pattern) pattern-variable-tag) `(,r-lambda (,(cdr pattern)) ,body) (let ((instance (generate-uninterned-symbol))) `(,r-lambda (,instance) + ,@(if top-level `((,r-declare (NO-TYPE-CHECKS))) '()) (,r-and (,r-pair? ,instance) - (,(descend (car pattern) - `(,(descend (cdr pattern) body) - (,r-cdr ,instance))) + (,(descend #f (car pattern) + `(,(descend #f (cdr pattern) body) + (,r-cdr ,instance))) (,r-car ,instance)))))) (let ((instance (generate-uninterned-symbol))) `(,r-lambda (,instance) diff --git a/src/compiler/base/pmpars.scm b/src/compiler/base/pmpars.scm index fd15e9598..641c46f1b 100644 --- a/src/compiler/base/pmpars.scm +++ b/src/compiler/base/pmpars.scm @@ -108,7 +108,7 @@ USA. environment) environment)))) -(define compile-pattern-matchers? #f) +(define compile-pattern-matchers? #t) (define (make-rule-matcher pattern expression environment) ;; PATTERN-LOOKUP-2 and the compiled matchers require that there @@ -144,7 +144,9 @@ USA. ,@qualifiers (,r-lambda () ,body))))) `(,r-lambda ,outer-vars - (,(close-syntax 'DECLARE environment) (INTEGRATE ,@outer-vars)) + (,(close-syntax 'DECLARE environment) + (INTEGRATE ,@outer-vars) + (TYPE-CHECKS)) ,(if (and (null? inner-vars) (null? xforms)) qualified-body -- 2.25.1