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)
This commit is contained in:
Robby Findler 2012-01-02 10:04:44 -06:00
parent 6bf42855b8
commit 83758881c3

View File

@ -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