aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorArun Isaac2023-11-23 16:57:12 +0000
committerArun Isaac2023-11-23 19:02:58 +0000
commit00c911b1bd5aca3800e0263240968ad8f3fbefde (patch)
tree3fc19b4c98f42478dec2596000e4bd8fb01bf3fb
parent704bea74e954c44e22442ca7d28f20fd0e553194 (diff)
downloadccwl-00c911b1bd5aca3800e0263240968ad8f3fbefde.tar.gz
ccwl-00c911b1bd5aca3800e0263240968ad8f3fbefde.tar.lz
ccwl-00c911b1bd5aca3800e0263240968ad8f3fbefde.zip
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.
-rw-r--r--ccwl/ccwl.scm27
1 files changed, 13 insertions, 14 deletions
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)))