Fine-tune skeleton-accumulator representations for persistency/reuse and for potential speed benefit
This commit is contained in:
parent
c122add136
commit
7f65d9e452
|
@ -50,12 +50,12 @@
|
||||||
;; (MutableSet Assertion)
|
;; (MutableSet Assertion)
|
||||||
;; (MutableHash SkProj SkAcc))
|
;; (MutableHash SkProj SkAcc))
|
||||||
;; SkAcc = (skeleton-accumulator
|
;; SkAcc = (skeleton-accumulator
|
||||||
;; (MutableSet SkKey)
|
;; (Set SkKey)
|
||||||
;; (MutableSet (... -> Any)))
|
;; (MutableSeteq (... -> Any)))
|
||||||
;;
|
;;
|
||||||
(struct skeleton-continuation (cache table) #:transparent)
|
(struct skeleton-continuation (cache table) #:transparent)
|
||||||
(struct skeleton-matched-constant (cache table) #:transparent)
|
(struct skeleton-matched-constant (cache table) #:transparent)
|
||||||
(struct skeleton-accumulator (cache handlers) #:transparent)
|
(struct skeleton-accumulator ([cache #:mutable] handlers) #:transparent)
|
||||||
;;
|
;;
|
||||||
;; A `SkProj` is a *skeleton projection*, a specification of loci
|
;; A `SkProj` is a *skeleton projection*, a specification of loci
|
||||||
;; within a tree-shaped assertion to collect into a flat list.
|
;; within a tree-shaped assertion to collect into a flat list.
|
||||||
|
@ -111,9 +111,9 @@
|
||||||
(define cvt (hash-ref! (skeleton-continuation-table c) cs make-hash))
|
(define cvt (hash-ref! (skeleton-continuation-table c) cs make-hash))
|
||||||
(define sc (hash-ref! cvt cv make-matched-constant))
|
(define sc (hash-ref! cvt cv make-matched-constant))
|
||||||
(define (make-accumulator)
|
(define (make-accumulator)
|
||||||
(skeleton-accumulator (for/mutable-set [(a (skeleton-matched-constant-cache sc))]
|
(skeleton-accumulator (for/set [(a (skeleton-matched-constant-cache sc))]
|
||||||
(apply-projection a vs))
|
(apply-projection a vs))
|
||||||
(mutable-set)))
|
(mutable-seteq)))
|
||||||
(define acc (hash-ref! (skeleton-matched-constant-table sc) vs make-accumulator))
|
(define acc (hash-ref! (skeleton-matched-constant-table sc) vs make-accumulator))
|
||||||
(set-add! (skeleton-accumulator-handlers acc) h)
|
(set-add! (skeleton-accumulator-handlers acc) h)
|
||||||
(for [(vars (skeleton-accumulator-cache acc))] (apply-handler! h vars)))
|
(for [(vars (skeleton-accumulator-cache acc))] (apply-handler! h vars)))
|
||||||
|
@ -229,8 +229,7 @@
|
||||||
(define (add-term-to-skconst! skconst term)
|
(define (add-term-to-skconst! skconst term)
|
||||||
(set-add! (skeleton-matched-constant-cache skconst) term))
|
(set-add! (skeleton-matched-constant-cache skconst) term))
|
||||||
(define (add-term-to-skacc! skacc vars _term)
|
(define (add-term-to-skacc! skacc vars _term)
|
||||||
(define cache (skeleton-accumulator-cache skacc))
|
(set-skeleton-accumulator-cache! skacc (set-add (skeleton-accumulator-cache skacc) vars))
|
||||||
(set-add! cache vars)
|
|
||||||
(for [(handler (skeleton-accumulator-handlers skacc))]
|
(for [(handler (skeleton-accumulator-handlers skacc))]
|
||||||
(apply handler '+ vars)))
|
(apply handler '+ vars)))
|
||||||
|
|
||||||
|
@ -246,8 +245,7 @@
|
||||||
(define (remove-term-from-skconst! skconst term)
|
(define (remove-term-from-skconst! skconst term)
|
||||||
(set-remove! (skeleton-matched-constant-cache skconst) term))
|
(set-remove! (skeleton-matched-constant-cache skconst) term))
|
||||||
(define (remove-term-from-skacc! skacc vars _term)
|
(define (remove-term-from-skacc! skacc vars _term)
|
||||||
(define cache (skeleton-accumulator-cache skacc))
|
(set-skeleton-accumulator-cache! skacc (set-remove (skeleton-accumulator-cache skacc) vars))
|
||||||
(set-remove! cache vars)
|
|
||||||
(for [(handler (skeleton-accumulator-handlers skacc))]
|
(for [(handler (skeleton-accumulator-handlers skacc))]
|
||||||
(apply handler '- vars)))
|
(apply handler '- vars)))
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue