From 069cca6f7459da5cc502d0c51f60a9813c611b31 Mon Sep 17 00:00:00 2001 From: Nobuyoshi Nakada Date: Sat, 1 Jan 2022 15:41:00 +0900 Subject: Negative RBOOL usage --- cont.c | 2 +- dir.c | 2 +- gc.c | 4 ++-- io.c | 2 +- numeric.c | 2 +- object.c | 8 ++++---- proc.c | 2 +- vm_insnhelper.c | 4 ++-- vm_method.c | 2 +- 9 files changed, 14 insertions(+), 14 deletions(-) diff --git a/cont.c b/cont.c index 4b18ddda67..96654733f8 100644 --- a/cont.c +++ b/cont.c @@ -2483,7 +2483,7 @@ rb_fiber_reset_root_local_storage(rb_thread_t *th) VALUE rb_fiber_alive_p(VALUE fiber_value) { - return FIBER_TERMINATED_P(fiber_ptr(fiber_value)) ? Qfalse : Qtrue; + return RBOOL(!FIBER_TERMINATED_P(fiber_ptr(fiber_value))); } /* diff --git a/dir.c b/dir.c index 1a3ba82070..8bd03679f1 100644 --- a/dir.c +++ b/dir.c @@ -3323,7 +3323,7 @@ rb_dir_s_empty_p(VALUE obj, VALUE dirname) al.dirattr = ATTR_DIR_ENTRYCOUNT; if (getattrlist(path, &al, attrbuf, sizeof(attrbuf), 0) == 0) { if (attrbuf[0] >= 2 * sizeof(u_int32_t)) - return attrbuf[1] ? Qfalse : Qtrue; + return RBOOL(attrbuf[1] == 0); if (false_on_notdir) return Qfalse; } rb_sys_fail_path(orig); diff --git a/gc.c b/gc.c index bbc5c40e90..0f44ff5c98 100644 --- a/gc.c +++ b/gc.c @@ -8600,7 +8600,7 @@ rb_copy_wb_protected_attribute(VALUE dest, VALUE obj) VALUE rb_obj_rgengc_writebarrier_protected_p(VALUE obj) { - return RVALUE_WB_UNPROTECTED(obj) ? Qfalse : Qtrue; + return RBOOL(!RVALUE_WB_UNPROTECTED(obj)); } VALUE @@ -12343,7 +12343,7 @@ wmap_aref(VALUE self, VALUE key) static VALUE wmap_has_key(VALUE self, VALUE key) { - return wmap_lookup(self, key) == Qundef ? Qfalse : Qtrue; + return RBOOL(wmap_lookup(self, key) != Qundef); } /* Returns the number of referenced objects */ diff --git a/io.c b/io.c index 3fab54e406..67d865650c 100644 --- a/io.c +++ b/io.c @@ -8933,7 +8933,7 @@ rb_io_autoclose_p(VALUE io) { rb_io_t *fptr = RFILE(io)->fptr; rb_io_check_closed(fptr); - return (fptr->mode & FMODE_PREP) ? Qfalse : Qtrue; + return RBOOL(!(fptr->mode & FMODE_PREP)); } /* diff --git a/numeric.c b/numeric.c index 9d5695de23..3165556a7f 100644 --- a/numeric.c +++ b/numeric.c @@ -3657,7 +3657,7 @@ static VALUE int_anybits_p(VALUE num, VALUE mask) { mask = rb_to_int(mask); - return int_zero_p(rb_int_and(num, mask)) ? Qfalse : Qtrue; + return RBOOL(!int_zero_p(rb_int_and(num, mask))); } /* diff --git a/object.c b/object.c index a34d971606..49315c566c 100644 --- a/object.c +++ b/object.c @@ -204,7 +204,7 @@ VALUE rb_obj_hash(VALUE obj); MJIT_FUNC_EXPORTED VALUE rb_obj_not(VALUE obj) { - return RTEST(obj) ? Qfalse : Qtrue; + return RBOOL(!RTEST(obj)); } /** @@ -221,7 +221,7 @@ MJIT_FUNC_EXPORTED VALUE rb_obj_not_equal(VALUE obj1, VALUE obj2) { VALUE result = rb_funcall(obj1, id_eq, 1, obj2); - return RTEST(result) ? Qfalse : Qtrue; + return rb_obj_not(result); } VALUE @@ -1295,7 +1295,7 @@ true_or(VALUE obj, VALUE obj2) static VALUE true_xor(VALUE obj, VALUE obj2) { - return RTEST(obj2)?Qfalse:Qtrue; + return rb_obj_not(obj2); } @@ -1426,7 +1426,7 @@ static VALUE rb_obj_not_match(VALUE obj1, VALUE obj2) { VALUE result = rb_funcall(obj1, id_match, 1, obj2); - return RTEST(result) ? Qfalse : Qtrue; + return rb_obj_not(result); } diff --git a/proc.c b/proc.c index 6cdd7bd836..ab6cce8fb8 100644 --- a/proc.c +++ b/proc.c @@ -1604,7 +1604,7 @@ respond_to_missing_p(VALUE klass, VALUE obj, VALUE sym, int scope) if (obj == Qundef) return 0; if (rb_method_basic_definition_p(klass, rmiss)) return 0; - return RTEST(rb_funcall(obj, rmiss, 2, sym, scope ? Qfalse : Qtrue)); + return RTEST(rb_funcall(obj, rmiss, 2, sym, RBOOL(!scope))); } diff --git a/vm_insnhelper.c b/vm_insnhelper.c index e01d39de77..271b347d3b 100644 --- a/vm_insnhelper.c +++ b/vm_insnhelper.c @@ -5205,7 +5205,7 @@ vm_opt_neq(const rb_iseq_t *iseq, CALL_DATA cd, CALL_DATA cd_eq, VALUE recv, VAL VALUE val = opt_equality(iseq, recv, obj, cd_eq); if (val != Qundef) { - return RTEST(val) ? Qfalse : Qtrue; + return RBOOL(!RTEST(val)); } } @@ -5538,7 +5538,7 @@ static VALUE vm_opt_not(const rb_iseq_t *iseq, CALL_DATA cd, VALUE recv) { if (vm_method_cfunc_is(iseq, cd, recv, rb_obj_not)) { - return RTEST(recv) ? Qfalse : Qtrue; + return RBOOL(!RTEST(recv)); } else { return Qundef; diff --git a/vm_method.c b/vm_method.c index 38d03fbe2b..6867b5cf8c 100644 --- a/vm_method.c +++ b/vm_method.c @@ -2678,7 +2678,7 @@ basic_obj_respond_to(rb_execution_context_t *ec, VALUE obj, ID id, int pub) return FALSE; case 0: ret = basic_obj_respond_to_missing(ec, klass, obj, ID2SYM(id), - pub ? Qfalse : Qtrue); + RBOOL(!pub)); return RTEST(ret) && ret != Qundef; default: return TRUE; -- cgit v1.2.3