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)) (let loop ([rhss (if (or (null? term) (pair? term))
list-rhs list-rhs
non-list-rhs)] non-list-rhs)]
[ht #f]) [ans '()])
(cond (cond
[(null? rhss) [(null? rhss)
(if ht (if (null? ans)
(hash-map ht (λ (k v) k)) #f
#f)] ans)]
[else [else
(let ([mth (call-nt-proc/bindings (car rhss) term hole-info #f #f #f)]) (let ([mth (call-nt-proc/bindings (car rhss) term hole-info #f #f #f)])
(cond (cond
[mth [mth
(let ([ht (or ht (make-hash))]) (loop (cdr rhss) (append mth ans))]
(for-each (λ (x) (hash-set! ht x #t)) mth)
(loop (cdr rhss) ht))]
[else [else
(loop (cdr rhss) ht)]))])) (loop (cdr rhss) ans)]))]))
;; if we're not doing a decomposition, we just need ;; if we're not doing a decomposition, we just need
;; to find the first match, not all of the matches ;; to find the first match, not all of the matches