From 44c246c38e862357d51dcb1a245fe2f1b0d71e81 Mon Sep 17 00:00:00 2001 From: Justin Ethier Date: Fri, 8 Jun 2018 15:06:11 -0400 Subject: [PATCH] Force inlining of Cyc_is_null By redefining as a macro there is a large potential speed increase with certain programs, with very few changes on our end. --- include/cyclone/runtime.h | 3 +-- include/cyclone/types.h | 2 ++ runtime.c | 14 +++++++------- 3 files changed, 10 insertions(+), 9 deletions(-) diff --git a/include/cyclone/runtime.h b/include/cyclone/runtime.h index 690cb0b2..52c90ef7 100644 --- a/include/cyclone/runtime.h +++ b/include/cyclone/runtime.h @@ -440,9 +440,8 @@ int equal(object, object); object equalp(object, object); object Cyc_has_cycle(object lst); object Cyc_is_boolean(object o); -//object Cyc_is_pair(object o); #define Cyc_is_pair(o) ((is_object_type(o) && ((list) o)->tag == pair_tag) ? boolean_t : boolean_f) -object Cyc_is_null(object o); +#define Cyc_is_null(o) make_boolean(o == NULL) object Cyc_is_number(object o); object Cyc_is_complex(object o); object Cyc_is_real(object o); diff --git a/include/cyclone/types.h b/include/cyclone/types.h index 8a36c383..1d5fdcdf 100644 --- a/include/cyclone/types.h +++ b/include/cyclone/types.h @@ -626,6 +626,8 @@ typedef boolean_type *boolean; #define boolean_desc(x) (((boolean_type *) x)->desc) +#define make_boolean(x) (x ? boolean_t : boolean_f) + /** * @brief Symbols are similar to strings, but only one instance of each * unique symbol is created, so comparisons are O(1). diff --git a/runtime.c b/runtime.c index 791934f9..58b9e32b 100644 --- a/runtime.c +++ b/runtime.c @@ -1557,13 +1557,13 @@ object Cyc_is_boolean(object o) // return boolean_t; // return boolean_f; //} - -object Cyc_is_null(object o) -{ - if (o == NULL) - return boolean_t; - return boolean_f; -} +// +//object Cyc_is_null(object o) +//{ +// if (o == NULL) +// return boolean_t; +// return boolean_f; +//} object Cyc_is_number(object o) {