From 00c911b1bd5aca3800e0263240968ad8f3fbefde Mon Sep 17 00:00:00 2001 From: Arun Isaac Date: Thu, 23 Nov 2023 16:57:12 +0000 Subject: ccwl: Scan run-args only once when constructing inputs. * ccwl/ccwl.scm (run-arg-prefix): Operate on a specific run argument, rather than on a list of them. (command): Scan run-args only once when constructing inputs. --- ccwl/ccwl.scm | 27 +++++++++++++-------------- 1 file changed, 13 insertions(+), 14 deletions(-) (limited to 'ccwl') diff --git a/ccwl/ccwl.scm b/ccwl/ccwl.scm index d251409..e602f0b 100644 --- a/ccwl/ccwl.scm +++ b/ccwl/ccwl.scm @@ -335,17 +335,12 @@ RUN-ARGS. If such an input is not present in RUN-ARGS, return #f." (eq? run-arg-input input-id)))) run-args)) -(define (run-arg-prefix input-id run-args) - "Return the prefix of input identified by symbol INPUT-ID in -RUN-ARGS. If such an input is not present in RUN-ARGS, return #f." - (any (lambda (x) - (syntax-case x () - ((prefix input) (identifier? #'input) - (and (eq? (syntax->datum #'input) - input-id) - #'prefix)) - (_ #f))) - run-args)) +(define (run-arg-prefix run-arg) + "Return the prefix specified in @var{run-arg} syntax. If not a prefixed +input, return #f." + (syntax-case run-arg () + ((prefix _) #'prefix) + (_ #f))) (define (run-args run defined-input-identifiers) "Return a list of run arguments specified in @var{run} @@ -432,11 +427,15 @@ identifiers defined in the commands." (ensure-yaml-serializable other "#:other") #`(make-command (list #,@(map (lambda (input-spec) - (let ((id (input-spec-id input-spec))) + (let* ((id (input-spec-id input-spec)) + (position (run-arg-position id run)) + (run-arg (and position + (list-ref run position)))) #`(set-input-prefix (set-input-position #,(input input-spec) - #,(run-arg-position id run)) - #,(run-arg-prefix id run)))) + #,position) + #,(and run-arg + (run-arg-prefix run-arg))))) inputs)) (list #,@(map output outputs)) (list #,@(run-args run (map input-spec-id inputs))) -- cgit v1.2.3