small improvements to the memory usage for files opened in DrRacket.

Before this commit, opening collects/drracket/private/unit.rkt required
about 17.5 megabytes of memory and after this commit, it is down to
about 15 megabytes.

The precise measurement I did was to create a frame and a scheme:text%
object in it, record the result of current-memory-use, open the file,
and record current-memory-use again.

For comparison, using a text:standard-style-list% object instead of
the scheme:text% requires only about 4.1 megabytes. One difference
being that there are about 3x more snips (10,204 vs 33,901 (after the
commit)), since we have one snip for each region that has a different
color in the scheme:text version, and the text:standard-style-list has
no colors and thus about two per line (there are 5006 lines in the
file).
This commit is contained in:
Robby Findler 2012-03-10 20:08:26 -06:00
parent 2811af1e59
commit a7cb8fdc84
4 changed files with 10 additions and 3 deletions

View File

@ -30,7 +30,7 @@ added get-regions
(init-depend framework:text^ framework:mode^)
(define (should-color-type? type)
(not (memq type '(white-space no-color))))
(not (memq type '(no-color))))
(define (make-data type mode backup-delta)
(if (zero? backup-delta)

View File

@ -328,7 +328,10 @@
[(sexp-comment) 'comment]
[else sym]))
(define sn-hash (make-hasheq))
(define (short-sym->style-name sym)
(define (short-sym->style-name _sym)
(define sym (if (eq? _sym 'white-space)
'parenthesis
_sym))
(hash-ref sn-hash sym
(λ ()
(let ([s (format "framework:syntax-color:scheme:~a"

View File

@ -405,7 +405,7 @@
(set! s-flags (add-flag (add-flag s-flags IS-TEXT) CAN-APPEND))
(let ([len (max 20 (* 2 (min len 5000)))])
(let ([len (max 8 (* 2 (min len 5000)))])
(set! s-buffer (make-string len)))
(set! s-snipclass the-string-snip-class)

View File

@ -5,6 +5,10 @@
. DrRacket's toolbar buttons now have numbers associated with them
to control what order they appear in.
. The framework's color:text%'s token-sym->style init argument (also
the same as the color:text%'s start-colorer method's argument of
the same name) is a function that now might be passed 'white-space.
------------------------------
Version 5.2.1
------------------------------