Avoid consing and canonicalizing on every call to expand
This commit is contained in:
parent
482852a6d6
commit
515f8fd9a7
|
@ -264,10 +264,12 @@
|
||||||
;; Trie -> Trie
|
;; Trie -> Trie
|
||||||
;; Given a non-empty trie, returns it; otherwise, returns a branch
|
;; Given a non-empty trie, returns it; otherwise, returns a branch
|
||||||
;; that is equivalent to the empty trie. Inverse of `collapse`.
|
;; that is equivalent to the empty trie. Inverse of `collapse`.
|
||||||
(define (expand r)
|
(define expand
|
||||||
(if (trie-empty? r)
|
(let ((canonical-expanded-empty (canonicalize (branch empty-omap trie-empty empty-smap))))
|
||||||
(canonicalize (branch empty-omap trie-empty empty-smap))
|
(lambda (r)
|
||||||
r))
|
(if (trie-empty? r)
|
||||||
|
canonical-expanded-empty
|
||||||
|
r))))
|
||||||
|
|
||||||
;; Sigma Trie -> Trie
|
;; Sigma Trie -> Trie
|
||||||
;; Prepends e to r, if r is non-empty.
|
;; Prepends e to r, if r is non-empty.
|
||||||
|
|
Loading…
Reference in New Issue