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
commited104dd48299712450c289908ec43f6e49468959 (patch)
treecbd36fd846b218c10b53fc1fb864d2b9e99431f5
parent85e80eb7f9dcc3e24b8a2d618525a4ce901d3982 (diff)
downloadtxr-ed104dd48299712450c289908ec43f6e49468959.tar.gz
txr-ed104dd48299712450c289908ec43f6e49468959.tar.bz2
txr-ed104dd48299712450c289908ec43f6e49468959.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)
{