Skip to content

Commit

Permalink
Reuse memoization for spaces doc constructor
Browse files Browse the repository at this point in the history
  • Loading branch information
jackfirth authored and sorawee committed Aug 15, 2024
1 parent e5669f9 commit c33ed62
Showing 1 changed file with 2 additions and 5 deletions.
7 changes: 2 additions & 5 deletions core.rkt
Original file line number Diff line number Diff line change
Expand Up @@ -142,11 +142,8 @@
(define-syntax-parse-rule (pretty-node args ...)
(pretty-node* doc args ...))

(define spaces-table (make-hasheq))

(define (spaces n)
(hash-ref! spaces-table n
(λ () (text (make-string n #\space)))))
(define/memoize (spaces n)
(text (make-string n #\space)))

(define (require-newline? d)
(or (and (commentable? d) (commentable-inline-comment d)) (line-comment? d) (newl? d) (full-atom? d)))
Expand Down

0 comments on commit c33ed62

Please sign in to comment.