From 83758881c3bd809fe4fe4bc3e3a5fcd271a7c487 Mon Sep 17 00:00:00 2001 From: Robby Findler Date: Mon, 2 Jan 2012 10:04:44 -0600 Subject: [PATCH] Don't attempt to drop duplicates in the non-terminal case This speeds up the lambdajs model considerably because the computation to determine duplicates is expensive and no duplicates are really ever dropped (and, in general, I think that duplicates will only be dropped when the grammar is ambiguous; so maybe a better thing is to just rewrite the grammar when that happens) --- collects/redex/private/matcher.rkt | 14 ++++++-------- 1 file changed, 6 insertions(+), 8 deletions(-) diff --git a/collects/redex/private/matcher.rkt b/collects/redex/private/matcher.rkt index 82752130b5..b8fa33b2ea 100644 --- a/collects/redex/private/matcher.rkt +++ b/collects/redex/private/matcher.rkt @@ -1554,21 +1554,19 @@ See match-a-pattern.rkt for more details (let loop ([rhss (if (or (null? term) (pair? term)) list-rhs non-list-rhs)] - [ht #f]) + [ans '()]) (cond [(null? rhss) - (if ht - (hash-map ht (λ (k v) k)) - #f)] + (if (null? ans) + #f + ans)] [else (let ([mth (call-nt-proc/bindings (car rhss) term hole-info #f #f #f)]) (cond [mth - (let ([ht (or ht (make-hash))]) - (for-each (λ (x) (hash-set! ht x #t)) mth) - (loop (cdr rhss) ht))] + (loop (cdr rhss) (append mth ans))] [else - (loop (cdr rhss) ht)]))])) + (loop (cdr rhss) ans)]))])) ;; if we're not doing a decomposition, we just need ;; to find the first match, not all of the matches