diff options
author | Kaz Kylheku <kaz@kylheku.com> | 2019-11-28 06:07:35 -0800 |
---|---|---|
committer | Kaz Kylheku <kaz@kylheku.com> | 2019-11-28 06:07:35 -0800 |
commit | 63f55d5881cdd7c8079b0de2722ed503273a3a29 (patch) | |
tree | b4ac26507b21f4afcc0e5f3811b0c887fcf1085b | |
parent | 1c2cc99d0da5863b1b5ca1ce1d5f3ecb50256179 (diff) | |
download | txr-63f55d5881cdd7c8079b0de2722ed503273a3a29.tar.gz txr-63f55d5881cdd7c8079b0de2722ed503273a3a29.tar.bz2 txr-63f55d5881cdd7c8079b0de2722ed503273a3a29.zip |
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.
-rw-r--r-- | share/txr/stdlib/getopts.tl | 8 |
1 files 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 "=")))) |