Skip to content

Commit 70b83e7

Browse files
committed
cache the computation of the tacked arrows x span
we still blow the budget on some calls to on-paint, but instead of 800 msec for 5000 arrows, it's more like 40-60 msec
1 parent 9d7d42a commit 70b83e7

File tree

1 file changed

+18
-5
lines changed
  • drracket-core-lib/drracket/private/syncheck

1 file changed

+18
-5
lines changed

drracket-core-lib/drracket/private/syncheck/gui.rkt

Lines changed: 18 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1285,6 +1285,8 @@ If the namespace does not, they are colored the unbound color.
12851285
(define tacked-arrows-to-draw '())
12861286
(define arrows-to-draw '())
12871287

1288+
(define arrow->matching-identifiers-hash (make-hash))
1289+
12881290
(for ([(arrow v) (in-hash tacked-hash-table)])
12891291
(when v
12901292
(define-values (arrow-text arrow-pos)
@@ -1293,11 +1295,22 @@ If the namespace does not, they are colored the unbound color.
12931295
(var-arrow-start-pos-left arrow))]
12941296
[(tail-arrow? arrow) (values (tail-arrow-from-text arrow)
12951297
(tail-arrow-from-pos arrow))]))
1296-
(define-values (_binders make-identifiers-hash)
1297-
(position->matching-identifiers-hash arrow-text arrow-pos arrow-pos
1298-
#:also-look-backward-one? #f))
1299-
(define-values (tacked-var-arrow-end-x-min tacked-var-arrow-end-x-max)
1300-
(get-var-arrow-end-x-min-and-max (make-identifiers-hash)))
1298+
(match-define (cons tacked-var-arrow-end-x-min tacked-var-arrow-end-x-max)
1299+
(match (hash-ref
1300+
arrow->matching-identifiers-hash
1301+
(cons arrow-text arrow-pos)
1302+
#f)
1303+
[#f
1304+
(define-values (_binders make-identifiers-hash)
1305+
(position->matching-identifiers-hash arrow-text arrow-pos arrow-pos
1306+
#:also-look-backward-one? #f))
1307+
(define-values (tacked-var-arrow-end-x-min tacked-var-arrow-end-x-max)
1308+
(get-var-arrow-end-x-min-and-max (make-identifiers-hash)))
1309+
(hash-set! arrow->matching-identifiers-hash (cons arrow-text arrow-pos)
1310+
(cons tacked-var-arrow-end-x-min tacked-var-arrow-end-x-max))
1311+
(cons tacked-var-arrow-end-x-min tacked-var-arrow-end-x-max)]
1312+
[(cons tacked-var-arrow-end-x-min tacked-var-arrow-end-x-max)
1313+
(cons tacked-var-arrow-end-x-min tacked-var-arrow-end-x-max)]))
13011314

13021315
(set! tacked-arrows-to-draw
13031316
(cons

0 commit comments

Comments
 (0)