diff options
-rw-r--r-- | ChangeLog | 40 | ||||
-rw-r--r-- | eval.c | 4 | ||||
-rw-r--r-- | filter.c | 14 | ||||
-rw-r--r-- | hash.c | 2 | ||||
-rw-r--r-- | lib.c | 15 | ||||
-rw-r--r-- | lib.h | 10 | ||||
-rw-r--r-- | match.c | 2 | ||||
-rw-r--r-- | rand.c | 2 | ||||
-rw-r--r-- | regex.c | 8 | ||||
-rw-r--r-- | stream.c | 20 | ||||
-rw-r--r-- | syslog.c | 2 |
11 files changed, 78 insertions, 41 deletions
@@ -1,5 +1,45 @@ 2014-02-22 Kaz Kylheku <kaz@kylheku.com> + 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. + +2014-02-22 Kaz Kylheku <kaz@kylheku.com> + The C function nullp is being renamed to null, and the rarely used global variable null which holds a symbol becomes null_s. @@ -1996,7 +1996,7 @@ static val transform_op(val forms, val syms, val rg) cdr(cell)); cons_bind (outsyms, outforms, transform_op(re, newsyms, rg)); return cons(outsyms, rlcp(cons(sym, outforms), outforms)); - } else if (eq(vararg, rest_s)) { + } else if (vararg == rest_s) { cons_bind (outsyms, outforms, transform_op(re, syms, rg)); return cons(outsyms, rlcp(cons(rg, outforms), outforms)); } @@ -2725,7 +2725,7 @@ static void c_var_mark(val obj) } static struct cobj_ops c_var_ops = { - cobj_equal_op, + eq, cobj_print_op, cobj_destroy_free_op, c_var_mark, @@ -93,7 +93,7 @@ static void trie_compress(val *ptrie) if (zerop(count)) { set(*ptrie, value); - } else if (eq(count, one) && nilp(value)) { + } else if (count == one && nilp(value)) { val iter = hash_begin(trie); val cell = hash_next(iter); set(*ptrie, cons(car(cell), cdr(cell))); @@ -131,7 +131,7 @@ val trie_lookup_feed_char(val node, val ch) return gethash(node, ch); if (functionp(node)) return funcall1(node, ch); - if (consp(node) && eq(ch,car(node))) + if (consp(node) && ch == car(node)) return cdr(node); return nil; } @@ -246,9 +246,9 @@ val filter_string_tree(val filter, val obj) { val type = typeof(filter); - if (eq(type, null_s)) + if (type == null_s) return obj; - if (eq(type, hash_s) || eq(type, cons_s)) + if (type == hash_s || type == cons_s) return trie_filter_string(filter, obj); else if (type == fun_s) return funcall1(filter, obj); @@ -549,7 +549,7 @@ static val html_hex_continue(val hexlist, val ch) { if (iswxdigit(c_chr(ch))) { return func_f1(cons(ch, hexlist), html_hex_continue); - } if (eq(ch, chr(';'))) { + } if (ch == chr(';')) { wchar_t out[2] = { 0 }; val iter; @@ -573,7 +573,7 @@ static val html_dec_continue(val declist, val ch) { if (iswdigit(c_chr(ch))) { return func_f1(cons(ch, declist), html_dec_continue); - } if (eq(ch, chr(';'))) { + } if (ch == chr(';')) { wchar_t out[2] = { 0 }; val iter; @@ -592,7 +592,7 @@ static val html_dec_continue(val declist, val ch) static val html_numeric_handler(val ch) { - if (eq(ch, chr('x'))) + if (ch == chr('x')) return func_f1(nil, html_hex_continue); if (!iswdigit(c_chr(ch))) return nil; @@ -637,7 +637,7 @@ static void hash_iter_mark(val hash_iter) } static struct cobj_ops hash_iter_ops = { - cobj_equal_op, + eq, cobj_print_op, cobj_destroy_free_op, hash_iter_mark, @@ -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; @@ -193,8 +193,10 @@ struct cobj_ops { cnum (*hash)(val self); }; -/* Default operations for above structure. */ -val cobj_equal_op(val, val); +/* Default operations for above structure. + * Default equal is eq + */ + void cobj_print_op(val, val); void cobj_destroy_stub_op(val); void cobj_destroy_free_op(val); @@ -725,9 +727,9 @@ INLINE val null(val v) { return v ? nil : t; } #define nao ((obj_t *) (1 << TAG_SHIFT)) /* "not an object" sentinel value. */ -INLINE val missingp(val v) { return v == colon_k ? t : nil; } +#define missingp(v) ((v) == colon_k) -INLINE val null_or_missing_p(val v) { return (!v || v == colon_k) ? t : nil; } +INLINE int null_or_missing_p(val v) { return (nilp(v) || missingp(v)); } #define if2(a, b) ((a) ? (b) : nil) @@ -3047,7 +3047,7 @@ static val v_output(match_files_ctx *c) val alist; fpip_t fp; - if (eq(first(dest_spec), nothrow_k)) { + if (first(dest_spec) == nothrow_k) { if (rest(dest_spec)) sem_error(specline, lit("material after :nothrow in output"), nao); } else if (!keywordp(first(dest_spec))) { @@ -63,7 +63,7 @@ val random_state; val random_state_s; static struct cobj_ops random_state_ops = { - cobj_equal_op, + eq, cobj_print_op, cobj_destroy_free_op, cobj_mark_op, @@ -761,7 +761,7 @@ static void char_set_cobj_destroy(val chset) } static struct cobj_ops char_set_obj_ops = { - cobj_equal_op, + eq, cobj_print_op, char_set_cobj_destroy, cobj_mark_op, @@ -1264,7 +1264,7 @@ static void regex_destroy(val regex) } static struct cobj_ops regex_obj_ops = { - cobj_equal_op, + eq, cobj_print_op, regex_destroy, cobj_mark_op, @@ -1501,7 +1501,7 @@ static val reg_derivative(val exp, val ch) if (exp == nil || exp == t) { return t; } else if (chrp(exp)) { - return if3(eq(exp, ch), nil, t); + return null(eq(exp, ch)); } else if (typeof(exp) == chset_s) { char_set_t *set = (char_set_t *) exp->co.handle; return if3(char_set_contains(set, c_chr(ch)), nil, t); @@ -1635,7 +1635,7 @@ val regex_compile(val regex_sexp, val error_stream) val regexp(val obj) { if (consp(obj)) - return if2(eq(car(obj), compiled_regex_s), t); + return eq(car(obj), compiled_regex_s); return typeof(obj) == regex_s ? t : nil; } @@ -87,7 +87,7 @@ static val null_get_prop(val stream, val ind) } static struct strm_ops null_ops = { - { cobj_equal_op, + { eq, null_stream_print, cobj_destroy_stub_op, cobj_mark_op, @@ -419,7 +419,7 @@ static val stdio_close(val stream, val throw_on_error) } static struct strm_ops stdio_ops = { - { cobj_equal_op, + { eq, stdio_stream_print, stdio_stream_destroy, stdio_stream_mark, @@ -599,7 +599,7 @@ static val tail_get_byte(val stream) static struct strm_ops tail_ops = { - { cobj_equal_op, + { eq, stdio_stream_print, stdio_stream_destroy, stdio_stream_mark, @@ -689,7 +689,7 @@ static val pipe_close(val stream, val throw_on_error) } static struct strm_ops pipe_ops = { - { cobj_equal_op, + { eq, stdio_stream_print, stdio_stream_destroy, stdio_stream_mark, @@ -791,7 +791,7 @@ static val string_in_get_prop(val stream, val ind) } static struct strm_ops string_in_ops = { - { cobj_equal_op, + { eq, cobj_print_op, cobj_destroy_stub_op, string_in_stream_mark, @@ -852,7 +852,7 @@ static val byte_in_unget_byte(val stream, int byte) } static struct strm_ops byte_in_ops = { - { cobj_equal_op, + { eq, cobj_print_op, byte_in_stream_destroy, cobj_mark_op, @@ -980,7 +980,7 @@ static val string_out_put_byte(val stream, int ch) } static struct strm_ops string_out_ops = { - { cobj_equal_op, + { eq, cobj_print_op, string_out_stream_destroy, cobj_mark_op, @@ -1053,7 +1053,7 @@ static val strlist_out_put_char(val stream, val ch) } static struct strm_ops strlist_out_ops = { - { cobj_equal_op, + { eq, cobj_print_op, cobj_destroy_stub_op, strlist_mark, @@ -1127,7 +1127,7 @@ static val dir_close(val stream, val throw_on_error) } static struct strm_ops dir_ops = { - { cobj_equal_op, + { eq, cobj_print_op, common_destroy, cobj_mark_op, @@ -2334,7 +2334,7 @@ static val cat_get_prop(val stream, val ind) } static struct strm_ops cat_stream_ops = { - { cobj_equal_op, + { eq, cat_stream_print, cobj_destroy_stub_op, cobj_mark_op, @@ -209,7 +209,7 @@ static val syslog_set_prop(val stream, val ind, val prop) } static struct strm_ops syslog_strm_ops = { - { cobj_equal_op, + { eq, cobj_print_op, cobj_destroy_stub_op, syslog_mark, |