summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorKaz Kylheku <kaz@kylheku.com>2016-05-07 19:29:28 -0700
committerKaz Kylheku <kaz@kylheku.com>2016-05-07 19:29:28 -0700
commit60478b74f6dc867dcf0fe09c5a97b2246fc4df3e (patch)
treecbd36fd846b218c10b53fc1fb864d2b9e99431f5
parent9c1067f68d92d074ad905a6fcc98b30f8737352a (diff)
downloadtxr-60478b74f6dc867dcf0fe09c5a97b2246fc4df3e.tar.gz
txr-60478b74f6dc867dcf0fe09c5a97b2246fc4df3e.tar.bz2
txr-60478b74f6dc867dcf0fe09c5a97b2246fc4df3e.zip
Avoid unnecessary evaluation in argument defaulting.
* lib.h (default_arg): Inline function becomes macro, so we can avoid evaluating the default value expression when it is not needed. * lib.c (default_arg): Declaration removed.
-rw-r--r--lib.c1
-rw-r--r--lib.h5
2 files changed, 1 insertions, 5 deletions
diff --git a/lib.c b/lib.c
index 51a862b5..c5d0b27e 100644
--- a/lib.c
+++ b/lib.c
@@ -140,7 +140,6 @@ val chr(wchar_t ch);
val eq(val a, val b);
val null(val v);
int null_or_missing_p(val v);
-val default_arg(val arg, val dfl);
val default_bool_arg(val arg);
#endif
diff --git a/lib.h b/lib.h
index 3dc75d61..18f7f6d9 100644
--- a/lib.h
+++ b/lib.h
@@ -1024,10 +1024,7 @@ INLINE int null_or_missing_p(val v) { return (nilp(v) || missingp(v)); }
#define tnil(c_cond) ((c_cond) ? t : nil)
-INLINE val default_arg(val arg, val dfl)
-{
- return if3(null_or_missing_p(arg), dfl, arg);
-}
+#define default_arg(arg, dfl) if3(null_or_missing_p(arg), dfl, arg)
INLINE val default_bool_arg(val arg)
{