Faster version of (boolean?)

This commit is contained in:
Justin Ethier 2018-06-08 17:53:46 -04:00
parent 0d53f329e9
commit 6bec04f9c4
2 changed files with 11 additions and 10 deletions

View file

@ -439,7 +439,8 @@ object Cyc_eq(object x, object y);
int equal(object, object); int equal(object, object);
object equalp(object, object); object equalp(object, object);
object Cyc_has_cycle(object lst); object Cyc_has_cycle(object lst);
object Cyc_is_boolean(object o); //object Cyc_is_boolean(object o);
#define Cyc_is_boolean(o) (make_boolean(o == boolean_f || o == boolean_t))
#define Cyc_is_pair(o) ((is_object_type(o) && ((list) o)->tag == pair_tag) ? boolean_t : boolean_f) #define Cyc_is_pair(o) ((is_object_type(o) && ((list) o)->tag == pair_tag) ? boolean_t : boolean_f)
#define Cyc_is_null(o) (make_boolean(o == NULL)) #define Cyc_is_null(o) (make_boolean(o == NULL))
//TODO: convert all of these to macros (if it makes sense, most should), and remove them from runtime.c: //TODO: convert all of these to macros (if it makes sense, most should), and remove them from runtime.c:

View file

@ -1542,15 +1542,15 @@ declare_num_cmp(Cyc_num_lt, Cyc_num_lt_op, Cyc_num_fast_lt_op, dispatch_num_lt
declare_num_cmp(Cyc_num_gte, Cyc_num_gte_op, Cyc_num_fast_gte_op, dispatch_num_gte, >=, CYC_BN_GTE); declare_num_cmp(Cyc_num_gte, Cyc_num_gte_op, Cyc_num_fast_gte_op, dispatch_num_gte, >=, CYC_BN_GTE);
declare_num_cmp(Cyc_num_lte, Cyc_num_lte_op, Cyc_num_fast_lte_op, dispatch_num_lte, <=, CYC_BN_LTE); declare_num_cmp(Cyc_num_lte, Cyc_num_lte_op, Cyc_num_fast_lte_op, dispatch_num_lte, <=, CYC_BN_LTE);
object Cyc_is_boolean(object o) //object Cyc_is_boolean(object o)
{ //{
if ((o != NULL) && // if ((o != NULL) &&
!is_value_type(o) && // !is_value_type(o) &&
((list) o)->tag == boolean_tag && ((boolean_f == o) || (boolean_t == o))) // ((list) o)->tag == boolean_tag && ((boolean_f == o) || (boolean_t == o)))
return boolean_t; // return boolean_t;
return boolean_f; // return boolean_f;
} //}
//
//object Cyc_is_pair(object o) //object Cyc_is_pair(object o)
//{ //{
// if (is_object_type(o) && ((list) o)->tag == pair_tag) // if (is_object_type(o) && ((list) o)->tag == pair_tag)