From 63f55d5881cdd7c8079b0de2722ed503273a3a29 Mon Sep 17 00:00:00 2001 From: Kaz Kylheku Date: Thu, 28 Nov 2019 06:07:35 -0800 Subject: getopts: simplify build-hash. share/txr/stdlib/getopts.tl (sys:opt-processor build-hash): Don't construct (list od.long od.short) twice and iterate through it twice; make just one and process it in one pass. --- share/txr/stdlib/getopts.tl | 8 +++----- 1 file changed, 3 insertions(+), 5 deletions(-) diff --git a/share/txr/stdlib/getopts.tl b/share/txr/stdlib/getopts.tl index 889258cc..9f2ec42c 100644 --- a/share/txr/stdlib/getopts.tl +++ b/share/txr/stdlib/getopts.tl @@ -157,14 +157,12 @@ (defmeth sys:opt-processor build-hash (me) (each ((od me.od-list)) - (each ((str (list od.long od.short))) - (when (and str [me.od-hash str]) - (error "opt-processor: duplicate option ~s" str))) (unless (or od.long od.short) (error "opt-processor: no short or long name in option ~s" od)) (each ((str (list od.long od.short))) - (when str - (set [me.od-hash str] od))))) + (when (and str [me.od-hash str]) + (error "opt-processor: duplicate option ~s" str)) + (set [me.od-hash str] od)))) (defmeth sys:opt-processor parse-long (me out opt : arg) (iflet ((ieq (unless (stringp arg) (break-str opt "=")))) -- cgit v1.2.3