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 ram-cache (make-hash))
(define (external-renderer) (define (get-external-render-proc v)
(match (setup:external-renderer) (cond
[(list (? module-path? mod) (? symbol? render-proc-id)) [(and (list? v)
(with-handlers ([exn:fail:filesystem:missing-module? (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))]) (lambda (e) (error 'external-renderer "cannot open module ~a" mod))])
(dynamic-require mod (dynamic-require mod
render-proc-id render-proc-id
(lambda () (error 'external-renderer "~a is not provided by ~a" render-proc-id mod))))] (lambda () (error 'external-renderer "~a is not provided by ~a" render-proc-id mod)))))]
[#f #f] [else (error 'setup:external-renderer "Value is not in the form '(module-path proc-id): ~v" v)]))
[(var v) (error 'setup:external-renderer "Value is not in the form '(module-path proc-id): ~a" v)]))
;; note that output and template order is reversed from typical ;; note that output and template order is reversed from typical
(define (render-to-file-base caller (define (render-to-file-base caller
@ -270,7 +274,11 @@
[(not render-cache-activated?) 'render-cache-deactivated] [(not render-cache-activated?) 'render-cache-deactivated]
[else #false])) [else #false]))
(when render-needed? (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 (define render-result
(cond (cond
[render-cache-activated? [render-cache-activated?

Loading…
Cancel
Save