serialize bluebox tables

Typically, the bluebox table includes keys that have interned parts,
so serialization can save space both on disk and in memory when the
bluebox information is reloaded.
This commit is contained in:
Matthew Flatt 2012-11-21 06:49:45 -07:00
parent e4e4d544f5
commit 693ff33bfc
2 changed files with 9 additions and 5 deletions

View File

@ -4,6 +4,7 @@
racket/class
racket/math
racket/runtime-path
racket/serialize
data/interval-map
setup/dirs
images/icons/misc
@ -43,7 +44,7 @@
(define pos (file-position port))
(list x
(+ (string->number first-line) pos)
(read port))))))))
(deserialize (read port)))))))))
(define files->tag->offset #f)

View File

@ -3,7 +3,8 @@
(prefix-in text: "text-render.rkt")
"base-render.rkt"
"core.rkt"
file/convertible)
file/convertible
racket/serialize)
(provide override-render-mixin-single
override-render-mixin-multi)
@ -23,7 +24,7 @@
[the-ri ri]
[the-text-p p])
(r-part part 'block index-table))
(define table-str (format "~s\n" index-table))
(define table-str (format "~s\n" (serialize index-table)))
(define cb.rktd
(cond
[multi?
@ -135,8 +136,10 @@
(define-values (after-line _3 _4) (port-next-location text-p))
(define txt-loc (cons before-position (- after-line before-line)))
(define ri (the-ri))
(for ([(k v) (in-hash ents)])
(hash-set! index-table k (cons txt-loc (hash-ref index-table k '())))))
(let ([k (tag-key k ri)])
(hash-set! index-table k (cons txt-loc (hash-ref index-table k '()))))))
(define (r-blockss+cont blockss mode index-table)
(for ([blocks (in-list blockss)])
@ -172,7 +175,7 @@
(when (pair? mode)
(define ents (cdr mode))
(define key (index-element-tag element))
(hash-set! ents key #t)))
(hash-set! ents (tag-key key (the-ri)) #t)))
(r-content (element-content element) mode index-table))