From 2da0f724923b300ab98a508018604f7d71863d62 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). original commit: a7cb8fdc84f3b592c812468e5e7486d4f7d5bbb6 --- collects/framework/private/color.rkt | 2 +- collects/framework/private/racket.rkt | 5 ++++- 2 files changed, 5 insertions(+), 2 deletions(-) diff --git a/collects/framework/private/color.rkt b/collects/framework/private/color.rkt index b64be91b..87ad45f5 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 dc5e36c1..92f1af66 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"