From a7cb8fdc84f3b592c812468e5e7486d4f7d5bbb6 Mon Sep 17 00:00:00 2001 From: Robby Findler Date: Sat, 10 Mar 2012 20:08:26 -0600 Subject: [PATCH] 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). --- collects/framework/private/color.rkt | 2 +- collects/framework/private/racket.rkt | 5 ++++- collects/racket/snip/private/snip.rkt | 2 +- doc/release-notes/drracket/HISTORY.txt | 4 ++++ 4 files changed, 10 insertions(+), 3 deletions(-) diff --git a/collects/framework/private/color.rkt b/collects/framework/private/color.rkt index b64be91b8f..87ad45f593 100644 --- a/collects/framework/private/color.rkt +++ b/collects/framework/private/color.rkt @@ -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) diff --git a/collects/framework/private/racket.rkt b/collects/framework/private/racket.rkt index dc5e36c124..92f1af6683 100644 --- a/collects/framework/private/racket.rkt +++ b/collects/framework/private/racket.rkt @@ -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" diff --git a/collects/racket/snip/private/snip.rkt b/collects/racket/snip/private/snip.rkt index 908784dc45..0cb5b1bd0b 100644 --- a/collects/racket/snip/private/snip.rkt +++ b/collects/racket/snip/private/snip.rkt @@ -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) diff --git a/doc/release-notes/drracket/HISTORY.txt b/doc/release-notes/drracket/HISTORY.txt index bd0b6ba617..f092d88d52 100644 --- a/doc/release-notes/drracket/HISTORY.txt +++ b/doc/release-notes/drracket/HISTORY.txt @@ -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 ------------------------------