Avoid pointless scan of entire table in collapse-wildcard-sequences
This commit is contained in:
parent
a86a0cd326
commit
1dc38bd9c1
|
@ -402,13 +402,27 @@
|
||||||
;; equivalent to (wildcard-sequence m'). This is nearly the inverse of
|
;; equivalent to (wildcard-sequence m'). This is nearly the inverse of
|
||||||
;; expand-wildseq.
|
;; expand-wildseq.
|
||||||
(define (collapse-wildcard-sequences m)
|
(define (collapse-wildcard-sequences m)
|
||||||
(match m
|
(if (hash? m)
|
||||||
[(hash-table ((== ?) (and w (wildcard-sequence wk)))
|
(case (hash-count m)
|
||||||
((? key-close?) k))
|
[(2)
|
||||||
(if (requal? k wk) w m)]
|
(if (and (hash-has-key? m ?)
|
||||||
[(hash-table ((== ?) (and w (wildcard-sequence wk))))
|
(hash-has-key? m EOS))
|
||||||
w]
|
(let ((w (hash-ref m ?))
|
||||||
[_ m]))
|
(k (hash-ref m EOS)))
|
||||||
|
(if (and (wildcard-sequence? w)
|
||||||
|
(requal? (wildcard-sequence-matcher w) k))
|
||||||
|
w
|
||||||
|
m))
|
||||||
|
m)]
|
||||||
|
[(1)
|
||||||
|
(if (hash-has-key? m ?)
|
||||||
|
(let ((w (hash-ref m ?)))
|
||||||
|
(if (wildcard-sequence? w)
|
||||||
|
w
|
||||||
|
m))
|
||||||
|
m)]
|
||||||
|
[else m])
|
||||||
|
m))
|
||||||
|
|
||||||
;; Sigma -> Boolean
|
;; Sigma -> Boolean
|
||||||
;; True iff k represents the start of a compound datum.
|
;; True iff k represents the start of a compound datum.
|
||||||
|
|
Loading…
Reference in New Issue