faster external render check

pull/253/head
Joel Dueck 4 years ago
parent 49da70c86d
commit 4e8da0faf1

@ -233,16 +233,20 @@
(define ram-cache (make-hash))
(define (external-renderer)
(match (setup:external-renderer)
[(list (? module-path? mod) (? symbol? render-proc-id))
(define (get-external-render-proc v)
(cond
[(and (list? v)
(eq? 2 (length v))
(module-path? (first v))
(symbol? (second v)))
(let ([mod (first v)]
[render-proc-id (second v)])
(with-handlers ([exn:fail:filesystem:missing-module?
(lambda (e) (error 'external-renderer "cannot open module ~a" mod))])
(dynamic-require mod
render-proc-id
(lambda () (error 'external-renderer "~a is not provided by ~a" render-proc-id mod))))]
[#f #f]
[(var v) (error 'setup:external-renderer "Value is not in the form '(module-path proc-id): ~a" v)]))
(lambda () (error 'external-renderer "~a is not provided by ~a" render-proc-id mod)))))]
[else (error 'setup:external-renderer "Value is not in the form '(module-path proc-id): ~v" v)]))
;; note that output and template order is reversed from typical
(define (render-to-file-base caller
@ -270,7 +274,11 @@
[(not render-cache-activated?) 'render-cache-deactivated]
[else #false]))
(when render-needed?
(define render-thunk (or maybe-render-thunk (λ () ((or (external-renderer) render) source-path template-path output-path)))) ; returns either string or bytes
(define render-thunk (or maybe-render-thunk
(λ () ((or (let ([val (setup:external-renderer)])
(and val (get-external-render-proc val)))
render)
source-path template-path output-path)))) ; returns either string or bytes
(define render-result
(cond
[render-cache-activated?

Loading…
Cancel
Save