summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorKaz Kylheku <kaz@kylheku.com>2021-07-14 20:31:55 -0700
committerKaz Kylheku <kaz@kylheku.com>2021-07-14 20:31:55 -0700
commit35b47325f3f99077cbc3b731bfe80b6ee2351d53 (patch)
treec205c6ee844e74548054eae4b7858ed53b50b2ff
parent341c562956ed292045c9069498dabf4e692340d1 (diff)
downloadtxr-35b47325f3f99077cbc3b731bfe80b6ee2351d53.tar.gz
txr-35b47325f3f99077cbc3b731bfe80b6ee2351d53.tar.bz2
txr-35b47325f3f99077cbc3b731bfe80b6ee2351d53.zip
lib: default_arg_strict becomes macro.
* lib.h (default_arg_strict): Inline function converted to macro, so that we can suppress the evaluation of the default expression if it is not required. The default_arg_strict idiom is being used all over the stream library now. The common default value expressions like std_out are macros that access the dynamic variable by symbol. We don't want to be wastefully doing that on each stream operation, whether or not a stream argument has been supplied.
-rw-r--r--lib.h5
1 files changed, 1 insertions, 4 deletions
diff --git a/lib.h b/lib.h
index 07ff1edf..7f227b53 100644
--- a/lib.h
+++ b/lib.h
@@ -1286,10 +1286,7 @@ INLINE val default_null_arg(val arg)
return if3(missingp(arg), nil, arg);
}
-INLINE val default_arg_strict(val arg, val dfl)
-{
- return if3(missingp(arg), dfl, arg);
-}
+#define default_arg_strict(arg, dfl) if3(missingp(arg), dfl, arg)
#define list_collect_decl(OUT, PTAIL) \
val OUT = nil; \