Skip to content

Commit

Permalink
No longer delay/thread load-collections-xref
Browse files Browse the repository at this point in the history
  • Loading branch information
greghendershott committed Oct 7, 2024
1 parent 6247114 commit 78a5f5a
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 12 deletions.
6 changes: 2 additions & 4 deletions racket/commands/help.rkt
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
racket/contract
racket/format
racket/match
"../identifier.rkt")
"../identifier.rkt")

(provide doc)

Expand All @@ -23,14 +23,12 @@
;; that case, let's always open the browser one consistent way -- in
;; Emacs using browse-url.

;; We are lazy-required so `delay`-ing would be N/A.
(define xref (load-collections-xref))

(define/contract (doc how str)
(-> how/c string? (or/c #f string?))
(->identifier how str stx->uri-string))

(define (stx->uri-string stx)
(define xref (load-collections-xref))
(match (and xref (xref-binding->definition-tag xref stx 0))
[(? tag? tag)
(define-values (path anchor) (xref-tag->path+anchor xref tag))
Expand Down
14 changes: 6 additions & 8 deletions racket/scribble.rkt
Original file line number Diff line number Diff line change
Expand Up @@ -43,8 +43,6 @@
(module+ test
(require rackunit))

(define xref-promise (delay/thread (load-collections-xref)))

;; When running on a machine with little memory, such as a small VPS
;; or AWS instance, I have seen the oom-killer terminate the process
;; after we try to handle a back end command that does some of these
Expand All @@ -63,7 +61,7 @@
(define/contract (binding->path+anchor stx)
(-> identifier? (or/c #f (cons/c path-string? (or/c #f string?))))
(with-less-memory-pressure
(let* ([xref (force xref-promise)]
(let* ([xref (load-collections-xref)]
[tag (xref-binding->definition-tag xref stx 0)]
[p+a (and tag (tag->path+anchor xref tag))])
p+a)))
Expand All @@ -90,7 +88,7 @@

(define/contract (identifier->bluebox stx)
(-> identifier? (or/c #f string?))
(match (xref-binding->definition-tag (force xref-promise) stx 0)
(match (xref-binding->definition-tag (load-collections-xref) stx 0)
[(? tag? tag) (get-bluebox-string tag)]
[_ #f]))

Expand Down Expand Up @@ -131,7 +129,7 @@
(define ((doc-index-names))
(with-less-memory-pressure
(with-parens
(define xref (force xref-promise))
(define xref (load-collections-xref))
(for* ([entry (in-list (xref-index xref))]
[desc (in-value (entry-desc entry))]
#:unless (hide-desc? desc)
Expand All @@ -141,7 +139,7 @@

(define (doc-index-lookup str)
(with-less-memory-pressure
(define xref (force xref-promise))
(define xref (load-collections-xref))
(define results
(for*/set ([entry (in-list (xref-index xref))]
[term (in-value (car (entry-words entry)))]
Expand Down Expand Up @@ -276,7 +274,7 @@
;; sorted by most likely to be desired.
(define (libs-exporting-documented sym-as-str)
(with-less-memory-pressure
(define xref (force xref-promise))
(define xref (load-collections-xref))
(define results
(for*/set ([entry (in-list (xref-index xref))]
[desc (in-value (entry-desc entry))]
Expand Down Expand Up @@ -306,7 +304,7 @@

(define (build-module-doc-path-index)
(delay/thread
(define xref (force xref-promise))
(define xref (load-collections-xref))
(for*/hash ([entry (in-list (xref-index xref))]
[desc (in-value (entry-desc entry))]
[module? (in-value (module-path-index-desc? desc))]
Expand Down

0 comments on commit 78a5f5a

Please sign in to comment.