From 4583bce7b2786054bd342e034d2f1b3c708c3cd7 Mon Sep 17 00:00:00 2001 From: Matthew Butterick Date: Fri, 8 Nov 2019 12:48:38 -0800 Subject: [PATCH] matchify loop --- pollen/private/ts.rktd | 2 +- pollen/render.rkt | 26 +++++++++----------------- 2 files changed, 10 insertions(+), 18 deletions(-) diff --git a/pollen/private/ts.rktd b/pollen/private/ts.rktd index 2c358ae..7048990 100644 --- a/pollen/private/ts.rktd +++ b/pollen/private/ts.rktd @@ -1 +1 @@ -1573245169 +1573246118 diff --git a/pollen/render.rkt b/pollen/render.rkt index d78fea4..07d155c 100644 --- a/pollen/render.rkt +++ b/pollen/render.rkt @@ -245,23 +245,15 @@ (define output-path (or maybe-output-path (->output-path source-path))) (unless output-path (raise-argument-error 'render "valid output path" output-path)) - - (define tests (list has/is-null-source? - has/is-preproc-source? - has/is-markup-source? - has/is-scribble-source? - has/is-markdown-source?)) - (define render-procs (list render-null-source - render-preproc-source - render-markup-or-markdown-source - render-scribble-source - render-markup-or-markdown-source)) - (define render-proc (for/first ([test (in-list tests)] - [render-proc (in-list render-procs)] - #:when (test source-path)) - render-proc)) - (unless render-proc - (raise-argument-error 'render (format "valid rendering function for ~a" source-path) render-proc)) + + (define render-proc + (match source-path + [(? has/is-null-source?) render-null-source] + [(? has/is-preproc-source?) render-preproc-source] + [(? has/is-markup-source?) render-markup-or-markdown-source] + [(? has/is-scribble-source?) render-scribble-source] + [(? has/is-markdown-source?) render-markup-or-markdown-source] + [_ (raise-argument-error 'render (format "valid rendering function for ~a" source-path) #false)])) (define template-path (or maybe-template-path (get-template-for source-path output-path)))