From debcf6f76029eec890192e8ee5b040b47120f91b Mon Sep 17 00:00:00 2001 From: Kaz Kylheku Date: Sat, 22 Feb 2014 01:21:46 -0800 Subject: Replacing uses of the eq function which are used only as C booleans, with just using the == operator. Removing cobj_equal_op since it's indistinguishable from eq. Streamlining missingp and null_or_missing_p. * eval.c (transform_op): eq to ==. (c_var_ops): cobj_equal_op to eq. * filter.c (trie_compress, trie_lookup_feed_char, filter_string_tree, html_hex_continue, html_dec_continue): eq to ==. * hash.c (hash_iter_ops): cobj_equal to eq. * lib.c (countq, getplist, getplist_f, search_str_tree, posq): eq to ==. (cobj_equal_op): Function removed. * lib.h (cobj_equal_op): Declaration removed. (missingp): Becomes a simple macro that yields a C boolean instead of t/nil val, because it's only used that way. (null_or_missing_p): Becomes inline function returning int. * match.c (v_output): eq to ==. * rand.c (random_state_ops): cobj_equal_op to eq. * regex.c (char_set_obj_ops, regex_obj_ops): cobj_equal_op to eq. (reg_derivative): Silly if3 expression replaced by null. (regexp): Redundant if2 expression wrapped around eq removed. * stream.c (null_ops, stdio_ops, tail_ops, pipe_ops, string_in_ops, byte_in_ops, string_out_ops, strlist_out_ops, dir_ops, cat_stream_ops): cobj_equal_op to eq. * syslog.c (syslog_strm_ops): cobj_equal_op to eq. --- lib.c | 15 +++++---------- 1 file changed, 5 insertions(+), 10 deletions(-) (limited to 'lib.c') diff --git a/lib.c b/lib.c index b082c7fe..7037585f 100644 --- a/lib.c +++ b/lib.c @@ -1014,7 +1014,7 @@ val countq(val obj, val list) val count = zero; for (; list; list = cdr(list)) - if (eq(car(list), obj)) + if (car(list) == obj) count = plus(count, one); return count; @@ -1276,11 +1276,6 @@ val equal(val left, val right) internal_error("unhandled case in equal function"); } -val cobj_equal_op(val left, val right) -{ - return eq(left, right); -} - static mem_t *malloc_low_bound, *malloc_high_bound; mem_t *chk_malloc(size_t size) @@ -1444,7 +1439,7 @@ val getplist(val list, val key) { for (; list; list = cdr(cdr(list))) { val ind = first(list); - if (eq(ind, key)) + if (ind == key) return second(list); } @@ -1455,7 +1450,7 @@ val getplist_f(val list, val key, val *found) { for (; list; list = cdr(cdr(list))) { val ind = first(list); - if (eq(ind, key)) { + if (ind == key) { *found = t; return second(list); } @@ -1979,7 +1974,7 @@ val search_str_tree(val haystack, val tree, val start_num, val from_end) val result = search_str_tree(haystack, car(tree), start_num, from_end); if (result) { cons_bind (pos, len, result); - if (!it || lt(pos, minpos) || (eq(pos, minpos) && gt(len, maxlen))) { + if (!it || lt(pos, minpos) || (pos == minpos && gt(len, maxlen))) { minpos = pos; maxlen = len; it = result; @@ -4815,7 +4810,7 @@ val posq(val obj, val list) val pos = zero; for (; list; list = cdr(list), pos = plus(pos, one)) - if (eq(car(list), obj)) + if (car(list) == obj) return pos; return nil; -- cgit v1.2.3