From c474319f09d75500a9b7925b6339cbb6420294d7 Mon Sep 17 00:00:00 2001 From: Robby Findler Date: Tue, 29 Jul 2008 14:00:43 +0000 Subject: [PATCH] improved the caching in the contour window drawing so it does allocation on each redraw svn: r10964 original commit: 8c022426f44253464bb4c4baec9e0358fd7a5a50 --- collects/framework/private/text.ss | 22 ++++++++++++++-------- 1 file changed, 14 insertions(+), 8 deletions(-) diff --git a/collects/framework/private/text.ss b/collects/framework/private/text.ss index 4c7fe7c4..0e56bf51 100644 --- a/collects/framework/private/text.ss +++ b/collects/framework/private/text.ss @@ -819,15 +819,22 @@ WARNING: printf is rebound in the body of the unit to always (set/f! lb 0) (set/f! rb 0)) - (define cache-function #f) - (define cache-str #f) + (define cache-function void) + (define cache-str (make-string 1 #\space)) + (define container-str (make-string 1 #\space)) + + (inherit get-text!) (define/override (draw dc x y left top right bottom dx dy draw-caret) - (let ([str (get-text 0 (get-count))]) - (when (or (not cache-function) - (not (equal? cache-str str))) - (set! cache-function (for-each/sections str)) - (set! cache-str str))) + (let ([len (get-count)]) + (unless (= len (string-length container-str)) + (set! container-str (make-string len #\space)) + (set! cache-function void)) + (get-text! container-str 0 len 0) + (unless (string=? container-str cache-str) + (set! cache-function (for-each/sections container-str)) + (set! cache-str (make-string len #\space)) + (get-text! cache-str 0 len 0))) (when (<= top y bottom) (cache-function dc x y))) @@ -989,7 +996,6 @@ WARNING: printf is rebound in the body of the unit to always (send delegate last-position) (send delegate last-position)) (loop (send snip next))))) - (for-each (λ (range) (send delegate unhighlight-range