summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorS.H <gamelinks007@gmail.com>2021-08-02 12:06:44 +0900
committerGitHub <noreply@github.com>2021-08-02 12:06:44 +0900
commit378e8cdad69e6ba995a024da2957719789f0679e (patch)
tree99ffe0f8055bc10cba3225fb5e7a906f5c3f4543
parent3688b476710def7290e32656b200fefc538366d0 (diff)
Using RBOOL macro
Notes
Notes: Merged: https://github.com/ruby/ruby/pull/4695 Merged-By: nobu <nobu@ruby-lang.org>
-rw-r--r--array.c4
-rw-r--r--compar.c12
-rw-r--r--cont.c9
-rw-r--r--encoding.c4
-rw-r--r--error.c8
-rw-r--r--file.c2
-rw-r--r--gc.c10
-rw-r--r--hash.c21
-rw-r--r--internal.h2
-rw-r--r--io.c19
-rw-r--r--load.c2
-rw-r--r--numeric.c45
-rw-r--r--object.c24
-rw-r--r--proc.c18
-rw-r--r--range.c11
-rw-r--r--re.c8
-rw-r--r--string.c13
-rw-r--r--thread.c34
-rw-r--r--thread_sync.c25
-rw-r--r--time.c7
-rw-r--r--vm.c18
-rw-r--r--vm_backtrace.c7
-rw-r--r--vm_eval.c7
-rw-r--r--vm_insnhelper.c60
-rw-r--r--vm_method.c8
-rw-r--r--vm_trace.c6
26 files changed, 127 insertions, 257 deletions
diff --git a/array.c b/array.c
index 36f712bcac9..bd323cd6b0a 100644
--- a/array.c
+++ b/array.c
@@ -2668,9 +2668,7 @@ rb_ary_length(VALUE ary)
static VALUE
rb_ary_empty_p(VALUE ary)
{
- if (RARRAY_LEN(ary) == 0)
- return Qtrue;
- return Qfalse;
+ return RBOOL(RARRAY_LEN(ary) == 0);
}
VALUE
diff --git a/compar.c b/compar.c
index 0de318525cf..7974017e2b7 100644
--- a/compar.c
+++ b/compar.c
@@ -105,8 +105,7 @@ cmpint(VALUE x, VALUE y)
static VALUE
cmp_gt(VALUE x, VALUE y)
{
- if (cmpint(x, y) > 0) return Qtrue;
- return Qfalse;
+ return RBOOL(cmpint(x, y) > 0);
}
/*
@@ -120,8 +119,7 @@ cmp_gt(VALUE x, VALUE y)
static VALUE
cmp_ge(VALUE x, VALUE y)
{
- if (cmpint(x, y) >= 0) return Qtrue;
- return Qfalse;
+ return RBOOL(cmpint(x, y) >= 0);
}
/*
@@ -135,8 +133,7 @@ cmp_ge(VALUE x, VALUE y)
static VALUE
cmp_lt(VALUE x, VALUE y)
{
- if (cmpint(x, y) < 0) return Qtrue;
- return Qfalse;
+ return RBOOL(cmpint(x, y) < 0);
}
/*
@@ -150,8 +147,7 @@ cmp_lt(VALUE x, VALUE y)
static VALUE
cmp_le(VALUE x, VALUE y)
{
- if (cmpint(x, y) <= 0) return Qtrue;
- return Qfalse;
+ return RBOOL(cmpint(x, y) <= 0);
}
/*
diff --git a/cont.c b/cont.c
index 22c5ce5e46e..099f85ad9fc 100644
--- a/cont.c
+++ b/cont.c
@@ -1085,12 +1085,7 @@ fiber_memsize(const void *ptr)
VALUE
rb_obj_is_fiber(VALUE obj)
{
- if (rb_typeddata_is_kind_of(obj, &fiber_data_type)) {
- return Qtrue;
- }
- else {
- return Qfalse;
- }
+ return RBOOL(rb_typeddata_is_kind_of(obj, &fiber_data_type));
}
static void
@@ -2351,7 +2346,7 @@ rb_fiber_transfer(VALUE fiber_value, int argc, const VALUE *argv)
VALUE
rb_fiber_blocking_p(VALUE fiber)
{
- return (fiber_ptr(fiber)->blocking == 0) ? Qfalse : Qtrue;
+ return RBOOL(fiber_ptr(fiber)->blocking != 0);
}
/*
diff --git a/encoding.c b/encoding.c
index 32d5a349ebb..0f3f7f2c531 100644
--- a/encoding.c
+++ b/encoding.c
@@ -662,7 +662,7 @@ rb_encdb_dummy(const char *name)
static VALUE
enc_dummy_p(VALUE enc)
{
- return ENC_DUMMY_P(must_encoding(enc)) ? Qtrue : Qfalse;
+ return RBOOL(ENC_DUMMY_P(must_encoding(enc)));
}
/*
@@ -678,7 +678,7 @@ enc_dummy_p(VALUE enc)
static VALUE
enc_ascii_compatible_p(VALUE enc)
{
- return rb_enc_asciicompat(must_encoding(enc)) ? Qtrue : Qfalse;
+ return RBOOL(rb_enc_asciicompat(must_encoding(enc)));
}
/*
diff --git a/error.c b/error.c
index 1f3f4ed3198..5ac0f0913ed 100644
--- a/error.c
+++ b/error.c
@@ -217,9 +217,7 @@ static VALUE
rb_warning_s_aref(VALUE mod, VALUE category)
{
rb_warning_category_t cat = rb_warning_category_from_name(category);
- if (rb_warning_category_enabled_p(cat))
- return Qtrue;
- return Qfalse;
+ return RBOOL(rb_warning_category_enabled_p(cat));
}
/*
@@ -1231,7 +1229,7 @@ rb_get_message(VALUE exc)
static VALUE
exc_s_to_tty_p(VALUE self)
{
- return rb_stderr_tty_p() ? Qtrue : Qfalse;
+ return RBOOL(rb_stderr_tty_p());
}
/*
@@ -1802,7 +1800,7 @@ static VALUE
nometh_err_init_attr(VALUE exc, VALUE args, int priv)
{
rb_ivar_set(exc, id_args, args);
- rb_ivar_set(exc, id_private_call_p, priv ? Qtrue : Qfalse);
+ rb_ivar_set(exc, id_private_call_p, RBOOL(priv));
return exc;
}
diff --git a/file.c b/file.c
index 0afee429dee..4ea8de6d20f 100644
--- a/file.c
+++ b/file.c
@@ -171,8 +171,6 @@ int flock(int, int);
#include "ruby/thread.h"
#include "ruby/util.h"
-#define RBOOL(v) ((v) ? Qtrue : Qfalse)
-
VALUE rb_cFile;
VALUE rb_mFileTest;
VALUE rb_cStat;
diff --git a/gc.c b/gc.c
index f6ea4fc6dec..ab7532b47fb 100644
--- a/gc.c
+++ b/gc.c
@@ -8600,7 +8600,7 @@ rb_obj_rgengc_writebarrier_protected_p(VALUE obj)
VALUE
rb_obj_rgengc_promoted_p(VALUE obj)
{
- return OBJ_PROMOTED(obj) ? Qtrue : Qfalse;
+ return RBOOL(OBJ_PROMOTED(obj));
}
size_t
@@ -10645,7 +10645,7 @@ rb_objspace_gc_enable(rb_objspace_t *objspace)
int old = dont_gc_val();
dont_gc_off();
- return old ? Qtrue : Qfalse;
+ return RBOOL(old);
}
static VALUE
@@ -10666,7 +10666,7 @@ gc_disable_no_rest(rb_objspace_t *objspace)
{
int old = dont_gc_val();
dont_gc_on();
- return old ? Qtrue : Qfalse;
+ return RBOOL(old);
}
VALUE
@@ -10718,7 +10718,7 @@ gc_set_auto_compact(rb_execution_context_t *ec, VALUE _, VALUE v)
static VALUE
gc_get_auto_compact(rb_execution_context_t *ec, VALUE _)
{
- return ruby_enable_autocompact ? Qtrue : Qfalse;
+ return RBOOL(ruby_enable_autocompact);
}
static int
@@ -12858,7 +12858,7 @@ static VALUE
gc_profile_enable_get(VALUE self)
{
rb_objspace_t *objspace = &rb_objspace;
- return objspace->profile.run ? Qtrue : Qfalse;
+ return RBOOL(objspace->profile.run);
}
/*
diff --git a/hash.c b/hash.c
index 32f1364c1a9..ca44118515a 100644
--- a/hash.c
+++ b/hash.c
@@ -1956,7 +1956,7 @@ static VALUE
rb_hash_s_ruby2_keywords_hash_p(VALUE dummy, VALUE hash)
{
Check_Type(hash, T_HASH);
- return (RHASH(hash)->basic.flags & RHASH_PASS_AS_KEYWORDS) ? Qtrue : Qfalse;
+ return RBOOL(RHASH(hash)->basic.flags & RHASH_PASS_AS_KEYWORDS);
}
/*
@@ -3029,7 +3029,7 @@ rb_hash_size_num(VALUE hash)
static VALUE
rb_hash_empty_p(VALUE hash)
{
- return RHASH_EMPTY_P(hash) ? Qtrue : Qfalse;
+ return RBOOL(RHASH_EMPTY_P(hash));
}
static int
@@ -3667,12 +3667,7 @@ rb_hash_values(VALUE hash)
MJIT_FUNC_EXPORTED VALUE
rb_hash_has_key(VALUE hash, VALUE key)
{
- if (hash_stlike_lookup(hash, key, NULL)) {
- return Qtrue;
- }
- else {
- return Qfalse;
- }
+ return RBOOL(hash_stlike_lookup(hash, key, NULL));
}
static int
@@ -4446,12 +4441,7 @@ rb_hash_compare_by_id(VALUE hash)
MJIT_FUNC_EXPORTED VALUE
rb_hash_compare_by_id_p(VALUE hash)
{
- if (RHASH_ST_TABLE_P(hash) && RHASH_ST_TABLE(hash)->type == &identhash) {
- return Qtrue;
- }
- else {
- return Qfalse;
- }
+ return RBOOL(RHASH_ST_TABLE_P(hash) && RHASH_ST_TABLE(hash)->type == &identhash);
}
VALUE
@@ -6053,8 +6043,7 @@ env_has_key(VALUE env, VALUE key)
const char *s;
s = env_name(key);
- if (getenv(s)) return Qtrue;
- return Qfalse;
+ return RBOOL(getenv(s));
}
/*
diff --git a/internal.h b/internal.h
index c3b3a799b18..883459bfa68 100644
--- a/internal.h
+++ b/internal.h
@@ -104,4 +104,6 @@ RUBY_SYMBOL_EXPORT_END
// but breakpoint is set in run.gdb, so `make gdb` can stop here.
#define bp() ruby_debug_breakpoint()
+#define RBOOL(v) ((v) ? Qtrue : Qfalse)
+
#endif /* RUBY_INTERNAL_H */
diff --git a/io.c b/io.c
index 16f2526e956..c4466581cc3 100644
--- a/io.c
+++ b/io.c
@@ -2375,13 +2375,10 @@ rb_io_eof(VALUE io)
READ_CHECK(fptr);
#if RUBY_CRLF_ENVIRONMENT
if (!NEED_READCONV(fptr) && NEED_NEWLINE_DECORATOR_ON_READ(fptr)) {
- return eof(fptr->fd) ? Qtrue : Qfalse;
+ return RBOOL(eof(fptr->fd));;
}
#endif
- if (io_fillbuf(fptr) < 0) {
- return Qtrue;
- }
- return Qfalse;
+ return RBOOL(io_fillbuf(fptr) < 0);
}
/*
@@ -2404,7 +2401,7 @@ rb_io_sync(VALUE io)
io = GetWriteIO(io);
GetOpenFile(io, fptr);
- return (fptr->mode & FMODE_SYNC) ? Qtrue : Qfalse;
+ return RBOOL(fptr->mode & FMODE_SYNC);
}
#ifdef HAVE_FSYNC
@@ -4589,9 +4586,7 @@ rb_io_isatty(VALUE io)
rb_io_t *fptr;
GetOpenFile(io, fptr);
- if (isatty(fptr->fd) == 0)
- return Qfalse;
- return Qtrue;
+ return RBOOL(isatty(fptr->fd) != 0);
}
#if defined(HAVE_FCNTL) && defined(F_GETFD) && defined(F_SETFD) && defined(FD_CLOEXEC)
@@ -5129,7 +5124,7 @@ rb_io_closed(VALUE io)
}
fptr = rb_io_get_fptr(io);
- return 0 <= fptr->fd ? Qfalse : Qtrue;
+ return RBOOL(0 > fptr->fd);
}
/*
@@ -5631,7 +5626,7 @@ rb_io_binmode_p(VALUE io)
{
rb_io_t *fptr;
GetOpenFile(io, fptr);
- return fptr->mode & FMODE_BINMODE ? Qtrue : Qfalse;
+ return RBOOL(fptr->mode & FMODE_BINMODE);
}
static const char*
@@ -13054,7 +13049,7 @@ argf_binmode_m(VALUE argf)
static VALUE
argf_binmode_p(VALUE argf)
{
- return ARGF.binmode ? Qtrue : Qfalse;
+ return RBOOL(ARGF.binmode);
}
/*
diff --git a/load.c b/load.c
index 9f0dde2860d..b2363690aac 100644
--- a/load.c
+++ b/load.c
@@ -1196,7 +1196,7 @@ rb_require_string(VALUE fname)
load_failed(fname);
}
- return result ? Qtrue : Qfalse;
+ return RBOOL(result);
}
VALUE
diff --git a/numeric.c b/numeric.c
index c60853f3559..5f7c16218a6 100644
--- a/numeric.c
+++ b/numeric.c
@@ -828,11 +828,11 @@ num_positive_p(VALUE num)
if (FIXNUM_P(num)) {
if (method_basic_p(rb_cInteger))
- return (SIGNED_VALUE)num > (SIGNED_VALUE)INT2FIX(0) ? Qtrue : Qfalse;
+ return RBOOL((SIGNED_VALUE)num > (SIGNED_VALUE)INT2FIX(0));
}
else if (RB_TYPE_P(num, T_BIGNUM)) {
if (method_basic_p(rb_cInteger))
- return BIGNUM_POSITIVE_P(num) && !rb_bigzero_p(num) ? Qtrue : Qfalse;
+ return RBOOL(BIGNUM_POSITIVE_P(num) && !rb_bigzero_p(num));
}
return rb_num_compare_with_zero(num, mid);
}
@@ -847,7 +847,7 @@ num_positive_p(VALUE num)
static VALUE
num_negative_p(VALUE num)
{
- return rb_num_negative_int_p(num) ? Qtrue : Qfalse;
+ return RBOOL(rb_num_negative_int_p(num));
}
@@ -1331,8 +1331,7 @@ num_equal(VALUE x, VALUE y)
VALUE result;
if (x == y) return Qtrue;
result = num_funcall1(y, id_eq, x);
- if (RTEST(result)) return Qtrue;
- return Qfalse;
+ return RBOOL(RTEST(result));
}
/*
@@ -1477,7 +1476,7 @@ rb_float_gt(VALUE x, VALUE y)
if (RB_TYPE_P(y, T_FIXNUM) || RB_TYPE_P(y, T_BIGNUM)) {
VALUE rel = rb_integer_float_cmp(y, x);
if (FIXNUM_P(rel))
- return -FIX2LONG(rel) > 0 ? Qtrue : Qfalse;
+ return RBOOL(-FIX2LONG(rel) > 0);
return Qfalse;
}
else if (RB_TYPE_P(y, T_FLOAT)) {
@@ -1514,7 +1513,7 @@ flo_ge(VALUE x, VALUE y)
if (RB_TYPE_P(y, T_FIXNUM) || RB_TYPE_P(y, T_BIGNUM)) {
VALUE rel = rb_integer_float_cmp(y, x);
if (FIXNUM_P(rel))
- return -FIX2LONG(rel) >= 0 ? Qtrue : Qfalse;
+ return RBOOL(-FIX2LONG(rel) >= 0);
return Qfalse;
}
else if (RB_TYPE_P(y, T_FLOAT)) {
@@ -1551,7 +1550,7 @@ flo_lt(VALUE x, VALUE y)
if (RB_TYPE_P(y, T_FIXNUM) || RB_TYPE_P(y, T_BIGNUM)) {
VALUE rel = rb_integer_float_cmp(y, x);
if (FIXNUM_P(rel))
- return -FIX2LONG(rel) < 0 ? Qtrue : Qfalse;
+ return RBOOL(-FIX2LONG(rel) < 0);
return Qfalse;
}
else if (RB_TYPE_P(y, T_FLOAT)) {
@@ -1588,7 +1587,7 @@ flo_le(VALUE x, VALUE y)
if (RB_TYPE_P(y, T_FIXNUM) || RB_TYPE_P(y, T_BIGNUM)) {
VALUE rel = rb_integer_float_cmp(y, x);
if (FIXNUM_P(rel))
- return -FIX2LONG(rel) <= 0 ? Qtrue : Qfalse;
+ return RBOOL(-FIX2LONG(rel) <= 0);
return Qfalse;
}
else if (RB_TYPE_P(y, T_FLOAT)) {
@@ -1660,7 +1659,7 @@ flo_is_nan_p(VALUE num)
{
double value = RFLOAT_VALUE(num);
- return isnan(value) ? Qtrue : Qfalse;
+ return RBOOL(isnan(value));
}
/*
@@ -3130,10 +3129,7 @@ VALUE
rb_int_odd_p(VALUE num)
{
if (FIXNUM_P(num)) {
- if (num & 2) {
- return Qtrue;
- }
- return Qfalse;
+ return RBOOL(num & 2);
}
else {
assert(RB_TYPE_P(num, T_BIGNUM));
@@ -3145,10 +3141,7 @@ static VALUE
int_even_p(VALUE num)
{
if (FIXNUM_P(num)) {
- if ((num & 2) == 0) {
- return Qtrue;
- }
- return Qfalse;
+ return RBOOL((num & 2) == 0);
}
else {
assert(RB_TYPE_P(num, T_BIGNUM));
@@ -4109,10 +4102,10 @@ fix_gt(VALUE x, VALUE y)
return Qfalse;
}
else if (RB_TYPE_P(y, T_BIGNUM)) {
- return rb_big_cmp(y, x) == INT2FIX(-1) ? Qtrue : Qfalse;
+ return RBOOL(rb_big_cmp(y, x) == INT2FIX(-1));
}
else if (RB_TYPE_P(y, T_FLOAT)) {
- return rb_integer_float_cmp(x, y) == INT2FIX(1) ? Qtrue : Qfalse;
+ return RBOOL(rb_integer_float_cmp(x, y) == INT2FIX(1));
}
else {
return rb_num_coerce_relop(x, y, '>');
@@ -4148,11 +4141,11 @@ fix_ge(VALUE x, VALUE y)
return Qfalse;
}
else if (RB_TYPE_P(y, T_BIGNUM)) {
- return rb_big_cmp(y, x) != INT2FIX(+1) ? Qtrue : Qfalse;
+ return RBOOL(rb_big_cmp(y, x) != INT2FIX(+1));
}
else if (RB_TYPE_P(y, T_FLOAT)) {
VALUE rel = rb_integer_float_cmp(x, y);
- return rel == INT2FIX(1) || rel == INT2FIX(0) ? Qtrue : Qfalse;
+ return RBOOL(rel == INT2FIX(1) || rel == INT2FIX(0));
}
else {
return rb_num_coerce_relop(x, y, idGE);
@@ -4187,10 +4180,10 @@ fix_lt(VALUE x, VALUE y)
return Qfalse;
}
else if (RB_TYPE_P(y, T_BIGNUM)) {
- return rb_big_cmp(y, x) == INT2FIX(+1) ? Qtrue : Qfalse;
+ return RBOOL(rb_big_cmp(y, x) == INT2FIX(+1));
}
else if (RB_TYPE_P(y, T_FLOAT)) {
- return rb_integer_float_cmp(x, y) == INT2FIX(-1) ? Qtrue : Qfalse;
+ return RBOOL(rb_integer_float_cmp(x, y) == INT2FIX(-1));
}
else {
return rb_num_coerce_relop(x, y, '<');
@@ -4226,11 +4219,11 @@ fix_le(VALUE x, VALUE y)
return Qfalse;
}
else if (RB_TYPE_P(y, T_BIGNUM)) {
- return rb_big_cmp(y, x) != INT2FIX(-1) ? Qtrue : Qfalse;
+ return RBOOL(rb_big_cmp(y, x) != INT2FIX(-1));
}
else if (RB_TYPE_P(y, T_FLOAT)) {
VALUE rel = rb_integer_float_cmp(x, y);
- return rel == INT2FIX(-1) || rel == INT2FIX(0) ? Qtrue : Qfalse;
+ return RBOOL(rel == INT2FIX(-1) || rel == INT2FIX(0));
}
else {
return rb_num_coerce_relop(x, y, idLE);
diff --git a/object.c b/object.c
index 3211e5775e1..31633f91db2 100644
--- a/object.c
+++ b/object.c
@@ -164,8 +164,7 @@ rb_equal(VALUE obj1, VALUE obj2)
if (result == Qundef) {
result = rb_funcall(obj1, id_eq, 1, obj2);
}
- if (RTEST(result)) return Qtrue;
- return Qfalse;
+ return RBOOL(RTEST(result));
}
/**
@@ -187,8 +186,7 @@ rb_eql(VALUE obj1, VALUE obj2)
if (result == Qundef) {
result = rb_funcall(obj1, id_eql, 1, obj2);
}
- if (RTEST(result)) return Qtrue;
- return Qfalse;
+ return RBOOL(RTEST(result));
}
/**
@@ -235,8 +233,7 @@ rb_eql(VALUE obj1, VALUE obj2)
MJIT_FUNC_EXPORTED VALUE
rb_obj_equal(VALUE obj1, VALUE obj2)
{
- if (obj1 == obj2) return Qtrue;
- return Qfalse;
+ return RBOOL(obj1 == obj2);
}
VALUE rb_obj_hash(VALUE obj);
@@ -605,7 +602,7 @@ rb_obj_size(VALUE self, VALUE args, VALUE obj)
static VALUE
block_given_p(rb_execution_context_t *ec, VALUE self)
{
- return rb_block_given_p() ? Qtrue : Qfalse;
+ return RBOOL(rb_block_given_p());
}
/**
@@ -843,8 +840,7 @@ VALUE
rb_obj_is_instance_of(VALUE obj, VALUE c)
{
c = class_or_module_required(c);
- if (rb_obj_class(obj) == c) return Qtrue;
- return Qfalse;
+ return RBOOL(rb_obj_class(obj) == c);
}
@@ -889,7 +885,7 @@ rb_obj_is_kind_of(VALUE obj, VALUE c)
VALUE cl = CLASS_OF(obj);
c = class_or_module_required(c);
- return class_search_ancestor(cl, RCLASS_ORIGIN(c)) ? Qtrue : Qfalse;
+ return RBOOL(class_search_ancestor(cl, RCLASS_ORIGIN(c)));
}
static VALUE
@@ -1335,7 +1331,7 @@ rb_obj_freeze(VALUE obj)
VALUE
rb_obj_frozen_p(VALUE obj)
{
- return OBJ_FROZEN(obj) ? Qtrue : Qfalse;
+ return RBOOL(OBJ_FROZEN(obj));
}
@@ -1453,7 +1449,7 @@ true_to_s(VALUE obj)
static VALUE
true_and(VALUE obj, VALUE obj2)
{
- return RTEST(obj2)?Qtrue:Qfalse;
+ return RBOOL(RTEST(obj2));
}
/*
@@ -3055,9 +3051,7 @@ rb_mod_cvar_defined(VALUE obj, VALUE iv)
static VALUE
rb_mod_singleton_p(VALUE klass)
{
- if (RB_TYPE_P(klass, T_CLASS) && FL_TEST(klass, FL_SINGLETON))
- return Qtrue;
- return Qfalse;
+ return RBOOL(RB_TYPE_P(klass, T_CLASS) && FL_TEST(klass, FL_SINGLETON));
}
/*! \private */
diff --git a/proc.c b/proc.c
index d048ba46f29..823d806ffd7 100644
--- a/proc.c
+++ b/proc.c
@@ -169,12 +169,7 @@ rb_proc_alloc(VALUE klass)
VALUE
rb_obj_is_proc(VALUE proc)
{
- if (rb_typeddata_is_kind_of(proc, &proc_data_type)) {
- return Qtrue;
- }
- else {
- return Qfalse;
- }
+ return RBOOL(rb_typeddata_is_kind_of(proc, &proc_data_type));
}
/* :nodoc: */
@@ -295,7 +290,7 @@ rb_proc_lambda_p(VALUE procval)
rb_proc_t *proc;
GetProcPtr(procval, proc);
- return proc->is_lambda ? Qtrue : Qfalse;
+ return RBOOL(proc->is_lambda);
}
/* Binding */
@@ -648,7 +643,7 @@ bind_local_variable_defined_p(VALUE bindval, VALUE sym)
GetBindingPtr(bindval, bind);
env = VM_ENV_ENVVAL_PTR(vm_block_ep(&bind->block));
- return get_local_variable_ptr(&env, lid) ? Qtrue : Qfalse;
+ return RBOOL(get_local_variable_ptr(&env, lid));
}
/*
@@ -1598,12 +1593,7 @@ static const rb_data_type_t method_data_type = {
VALUE
rb_obj_is_method(VALUE m)
{
- if (rb_typeddata_is_kind_of(m, &method_data_type)) {
- return Qtrue;
- }
- else {
- return Qfalse;
- }
+ return RBOOL(rb_typeddata_is_kind_of(m, &method_data_type));
}
static int
diff --git a/range.c b/range.c
index 7a297b1ed94..7d08a49eee7 100644
--- a/range.c
+++ b/range.c
@@ -40,7 +40,6 @@ static VALUE r_cover_p(VALUE, VALUE, VALUE, VALUE);
#define RANGE_SET_BEG(r, v) (RSTRUCT_SET(r, 0, v))
#define RANGE_SET_END(r, v) (RSTRUCT_SET(r, 1, v))
#define RANGE_SET_EXCL(r, v) (RSTRUCT_SET(r, 2, v))
-#define RBOOL(v) ((v) ? Qtrue : Qfalse)
#define EXCL(r) RTEST(RANGE_EXCL(r))
@@ -125,7 +124,7 @@ range_initialize_copy(VALUE range, VALUE orig)
static VALUE
range_exclude_end_p(VALUE range)
{
- return EXCL(range) ? Qtrue : Qfalse;
+ return RBOOL(EXCL(range));
}
static VALUE
@@ -137,9 +136,7 @@ recursive_equal(VALUE range, VALUE obj, int recur)
if (!rb_equal(RANGE_END(range), RANGE_END(obj)))
return Qfalse;
- if (EXCL(range) != EXCL(obj))
- return Qfalse;
- return Qtrue;
+ return RBOOL(EXCL(range) == EXCL(obj));
}
@@ -192,9 +189,7 @@ recursive_eql(VALUE range, VALUE obj, int recur)
if (!rb_eql(RANGE_END(range), RANGE_END(obj)))
return Qfalse;
- if (EXCL(range) != EXCL(obj))
- return Qfalse;
- return Qtrue;
+ return RBOOL(EXCL(range) == EXCL(obj));
}
/*
diff --git a/re.c b/re.c
index 64078aefd29..3bd9237683e 100644
--- a/re.c
+++ b/re.c
@@ -724,8 +724,7 @@ static VALUE
rb_reg_casefold_p(VALUE re)
{
rb_reg_check(re);
- if (RREGEXP_PTR(re)->options & ONIG_OPTION_IGNORECASE) return Qtrue;
- return Qfalse;
+ return RBOOL(RREGEXP_PTR(re)->options & ONIG_OPTION_IGNORECASE);
}
@@ -1389,10 +1388,7 @@ rb_backref_set_string(VALUE string, long pos, long len)
static VALUE
rb_reg_fixed_encoding_p(VALUE re)
{
- if (FL_TEST(re, KCODE_FIXED))
- return Qtrue;
- else
- return Qfalse;
+ return RBOOL(FL_TEST(re, KCODE_FIXED));
}
static VALUE
diff --git a/string.c b/string.c
index 0d6b02b1ddb..2c0140a02c3 100644
--- a/string.c
+++ b/string.c
@@ -2015,9 +2015,7 @@ rb_str_bytesize(VALUE str)
static VALUE
rb_str_empty(VALUE str)
{
- if (RSTRING_LEN(str) == 0)
- return Qtrue;
- return Qfalse;
+ return RBOOL(RSTRING_LEN(str) == 0);
}
/*
@@ -4629,7 +4627,7 @@ rb_str_include_range_p(VALUE beg, VALUE end, VALUE val, VALUE exclusive)
}
rb_str_upto_each(beg, end, RTEST(exclusive), include_range_i, (VALUE)&val);
- return NIL_P(val) ? Qtrue : Qfalse;
+ return RBOOL(NIL_P(val));
}
static VALUE
@@ -5962,8 +5960,7 @@ rb_str_include(VALUE str, VALUE arg)
StringValue(arg);
i = rb_str_index(str, arg, 0);
- if (i == -1) return Qfalse;
- return Qtrue;
+ return RBOOL(i != -1);
}
@@ -10470,7 +10467,7 @@ rb_str_valid_encoding_p(VALUE str)
{
int cr = rb_enc_str_coderange(str);
- return cr == ENC_CODERANGE_BROKEN ? Qfalse : Qtrue;
+ return RBOOL(cr != ENC_CODERANGE_BROKEN);
}
/*
@@ -10488,7 +10485,7 @@ rb_str_is_ascii_only_p(VALUE str)
{
int cr = rb_enc_str_coderange(str);
- return cr == ENC_CODERANGE_7BIT ? Qtrue : Qfalse;
+ return RBOOL(cr == ENC_CODERANGE_7BIT);
}
/**
diff --git a/thread.c b/thread.c
index 3c3f645dbdf..81c1aaab66a 100644
--- a/thread.c
+++ b/thread.c
@@ -2303,12 +2303,7 @@ rb_thread_pending_interrupt_p(int argc, VALUE *argv, VALUE target_thread)
if (!rb_obj_is_kind_of(err, rb_cModule)) {
rb_raise(rb_eTypeError, "class or module required for rescue clause");
}
- if (rb_threadptr_pending_interrupt_include_p(target_th, err)) {
- return Qtrue;
- }
- else {
- return Qfalse;
- }
+ return RBOOL(rb_threadptr_pending_interrupt_include_p(target_th, err));
}
else {
return Qtrue;
@@ -2955,7 +2950,7 @@ rb_thread_s_main(VALUE klass)
static VALUE
rb_thread_s_abort_exc(VALUE _)
{
- return GET_THREAD()->vm->thread_abort_on_exception ? Qtrue : Qfalse;
+ return RBOOL(GET_THREAD()->vm->thread_abort_on_exception);
}
@@ -3015,7 +3010,7 @@ rb_thread_s_abort_exc_set(VALUE self, VALUE val)
static VALUE
rb_thread_abort_exc(VALUE thread)
{
- return rb_thread_ptr(thread)->abort_on_exception ? Qtrue : Qfalse;
+ return RBOOL(rb_thread_ptr(thread)->abort_on_exception);
}
@@ -3085,7 +3080,7 @@ rb_thread_abort_exc_set(VALUE thread, VALUE val)
static VALUE
rb_thread_s_report_exc(VALUE _)
{
- return GET_THREAD()->vm->thread_report_on_exception ? Qtrue : Qfalse;
+ return RBOOL(GET_THREAD()->vm->thread_report_on_exception);
}
@@ -3141,7 +3136,7 @@ rb_thread_s_report_exc_set(VALUE self, VALUE val)
static VALUE
rb_thread_s_ignore_deadlock(VALUE _)
{
- return GET_THREAD()->vm->thread_ignore_deadlock ? Qtrue : Qfalse;
+ return RBOOL(GET_THREAD()->vm->thread_ignore_deadlock);
}
@@ -3192,7 +3187,7 @@ rb_thread_s_ignore_deadlock_set(VALUE self, VALUE val)
static VALUE
rb_thread_report_exc(VALUE thread)
{
- return rb_thread_ptr(thread)->report_on_exception ? Qtrue : Qfalse;
+ return RBOOL(rb_thread_ptr(thread)->report_on_exception);
}
@@ -3868,14 +3863,7 @@ rb_thread_variable_p(VALUE thread, VALUE key)
}
locals = rb_thread_local_storage(thread);
- if (rb_hash_lookup(locals, rb_to_symbol(key)) != Qnil) {
- return Qtrue;
- }
- else {
- return Qfalse;
- }
-
- return Qfalse;
+ return RBOOL(rb_hash_lookup(locals, rb_to_symbol(key)) != Qnil);
}
/*
@@ -4933,9 +4921,7 @@ thgroup_enclosed_p(VALUE group)
struct thgroup *data;
TypedData_Get_Struct(group, struct thgroup, &thgroup_data_type, data);
- if (data->enclosed)
- return Qtrue;
- return Qfalse;
+ return RBOOL(data->enclosed);
}
@@ -5095,7 +5081,7 @@ rb_thread_shield_release(VALUE self)
{
VALUE mutex = thread_shield_get_mutex(self);
rb_mutex_unlock(mutex);
- return rb_thread_shield_waiting(self) > 0 ? Qtrue : Qfalse;
+ return RBOOL(rb_thread_shield_waiting(self) > 0);
}
/*
@@ -5107,7 +5093,7 @@ rb_thread_shield_destroy(VALUE self)
VALUE mutex = thread_shield_get_mutex(self);
DATA_PTR(self) = 0;
rb_mutex_unlock(mutex);
- return rb_thread_shield_waiting(self) > 0 ? Qtrue : Qfalse;
+ return RBOOL(rb_thread_shield_waiting(self) > 0);
}
static VALUE
diff --git a/thread_sync.c b/thread_sync.c
index 44290136b33..ba5a78ca0a1 100644
--- a/thread_sync.c
+++ b/thread_sync.c
@@ -141,12 +141,7 @@ mutex_ptr(VALUE obj)
VALUE
rb_obj_is_mutex(VALUE obj)
{
- if (rb_typeddata_is_kind_of(obj, &mutex_data_type)) {
- return Qtrue;
- }
- else {
- return Qfalse;
- }
+ return RBOOL(rb_typeddata_is_kind_of(obj, &mutex_data_type));
}
static VALUE
@@ -190,7 +185,7 @@ rb_mutex_locked_p(VALUE self)
{
rb_mutex_t *mutex = mutex_ptr(self);
- return mutex->fiber ? Qtrue : Qfalse;
+ return RBOOL(mutex->fiber);
}
static void
@@ -261,12 +256,7 @@ static const rb_thread_t *patrol_thread = NULL;
static VALUE
mutex_owned_p(rb_fiber_t *fiber, rb_mutex_t *mutex)
{
- if (mutex->fiber == fiber) {
- return Qtrue;
- }
- else {
- return Qfalse;
- }
+ return RBOOL(mutex->fiber == fiber);
}
static VALUE
@@ -533,8 +523,7 @@ rb_mutex_wait_for(VALUE time)
{
rb_hrtime_t *rel = (rb_hrtime_t *)time;
/* permit spurious check */
- if (sleep_hrtime(GET_THREAD(), *rel, 0)) return Qtrue;
- return Qfalse;
+ return RBOOL(sleep_hrtime(GET_THREAD(), *rel, 0));
}
VALUE
@@ -943,7 +932,7 @@ rb_queue_close(VALUE self)
static VALUE
rb_queue_closed_p(VALUE self)
{
- return queue_closed_p(self) ? Qtrue : Qfalse;
+ return RBOOL(queue_closed_p(self));
}
/*
@@ -1074,7 +1063,7 @@ rb_queue_pop(int argc, VALUE *argv, VALUE self)
static VALUE
rb_queue_empty_p(VALUE self)
{
- return queue_length(self, queue_ptr(self)) == 0 ? Qtrue : Qfalse;
+ return RBOOL(queue_length(self, queue_ptr(self)) == 0);
}
/*
@@ -1372,7 +1361,7 @@ rb_szqueue_empty_p(VALUE self)
{
struct rb_szqueue *sq = szqueue_ptr(self);
- return queue_length(self, &sq->q) == 0 ? Qtrue : Qfalse;
+ return RBOOL(queue_length(self, &sq->q) == 0);
}
diff --git a/time.c b/time.c
index 9f5e4d3238d..58e20304ed6 100644
--- a/time.c
+++ b/time.c
@@ -3677,8 +3677,7 @@ time_utc_p(VALUE time)
struct time_object *tobj;
GetTimeval(time, tobj);
- if (TZMODE_UTC_P(tobj)) return Qtrue;
- return Qfalse;
+ return RBOOL(TZMODE_UTC_P(tobj));
}
/*
@@ -4631,7 +4630,7 @@ time_isdst(VALUE time)
if (tobj->vtm.isdst == VTM_ISDST_INITVAL) {
rb_raise(rb_eRuntimeError, "isdst is not set yet");
}
- return tobj->vtm.isdst ? Qtrue : Qfalse;
+ return RBOOL(tobj->vtm.isdst);
}
/*
@@ -4732,7 +4731,7 @@ time_to_a(VALUE time)
tobj->vtm.year,
INT2FIX(tobj->vtm.wday),
INT2FIX(tobj->vtm.yday),
- tobj->vtm.isdst?Qtrue:Qfalse,
+ RBOOL(tobj->vtm.isdst),
time_zone(time));
}
diff --git a/vm.c b/vm.c
index 8a044efa1f2..b743bbf413c 100644
--- a/vm.c
+++ b/vm.c
@@ -3000,12 +3000,7 @@ const rb_data_type_t ruby_threadptr_data_type = {
VALUE
rb_obj_is_thread(VALUE obj)
{
- if (rb_typeddata_is_kind_of(obj, &thread_data_type)) {
- return Qtrue;
- }
- else {
- return Qfalse;
- }
+ return RBOOL(rb_typeddata_is_kind_of(obj, &thread_data_type));
}
static VALUE
@@ -3222,7 +3217,7 @@ core_hash_merge_kwd(VALUE hash, VALUE kw)
static VALUE
jit_enabled_p(VALUE _)
{
- return mjit_enabled ? Qtrue : Qfalse;
+ return RBOOL(mjit_enabled);
}
static VALUE
@@ -3978,24 +3973,21 @@ usage_analysis_register_stop(VALUE self)
static VALUE
usage_analysis_insn_running(VALUE self)
{
- if (ruby_vm_collect_usage_func_insn == 0) return Qfalse;
- return Qtrue;
+ return RBOOL(ruby_vm_collect_usage_func_insn != 0);
}
/* :nodoc: */
static VALUE
usage_analysis_operand_running(VALUE self)
{
- if (ruby_vm_collect_usage_func_operand == 0) return Qfalse;
- return Qtrue;
+ return RBOOL(ruby_vm_collect_usage_func_operand != 0);
}
/* :nodoc: */
static VALUE
usage_analysis_register_running(VALUE self)
{
- if (ruby_vm_collect_usage_func_register == 0) return Qfalse;
- return Qtrue;
+ return RBOOL(ruby_vm_collect_usage_func_register != 0);
}
/* :nodoc: */
diff --git a/vm_backtrace.c b/vm_backtrace.c
index 670f73d2a25..ac620c6063a 100644
--- a/vm_backtrace.c
+++ b/vm_backtrace.c
@@ -1741,12 +1741,7 @@ rb_profile_frame_singleton_method_p(VALUE frame)
{
VALUE klass = frame2klass(frame);
- if (klass && !NIL_P(klass) && FL_TEST(klass, FL_SINGLETON)) {
- return Qtrue;
- }
- else {
- return Qfalse;
- }
+ return RBOOL(klass && !NIL_P(klass) && FL_TEST(klass, FL_SINGLETON));
}
VALUE
diff --git a/vm_eval.c b/vm_eval.c
index 19ba6dd96bf..6d4b5c3c0b2 100644
--- a/vm_eval.c
+++ b/vm_eval.c
@@ -2568,12 +2568,7 @@ rb_f_block_given_p(VALUE _)
rb_control_frame_t *cfp = ec->cfp;
cfp = vm_get_ruby_level_caller_cfp(ec, RUBY_VM_PREVIOUS_CONTROL_FRAME(cfp));
- if (cfp != NULL && VM_CF_BLOCK_HANDLER(cfp) != VM_BLOCK_HANDLER_NONE) {
- return Qtrue;
- }
- else {
- return Qfalse;
- }
+ return RBOOL(cfp != NULL && VM_CF_BLOCK_HANDLER(cfp) != VM_BLOCK_HANDLER_NONE);
}
/*
diff --git a/vm_insnhelper.c b/vm_insnhelper.c
index 20863f971fc..14928b2afe8 100644
--- a/vm_insnhelper.c
+++ b/vm_insnhelper.c
@@ -2005,12 +2005,7 @@ opt_equality_specialized(VALUE recv, VALUE obj)
}
else
#endif
- if (a == b) {
- return Qtrue;
- }
- else {
- return Qfalse;
- }
+ return RBOOL(a == b);
}
else if (RBASIC_CLASS(recv) == rb_cString && EQ_UNREDEFINED_P(STRING)) {
if (recv == obj) {
@@ -2023,12 +2018,7 @@ opt_equality_specialized(VALUE recv, VALUE obj)
return Qundef;
compare_by_identity:
- if (recv == obj) {
- return Qtrue;
- }
- else {
- return Qfalse;
- }
+ return RBOOL(recv == obj);
}
static VALUE
@@ -2043,12 +2033,7 @@ opt_equality(const rb_iseq_t *cd_owner, VALUE recv, VALUE obj, CALL_DATA cd)
return Qundef;
}
else {
- if (recv == obj) {
- return Qtrue;
- }
- else {
- return Qfalse;
- }
+ return RBOOL(recv == obj);
}
}
@@ -2065,12 +2050,7 @@ opt_equality_by_mid_slowpath(VALUE recv, VALUE obj, ID mid)
const struct rb_callcache *cc = gccct_method_search(GET_EC(), recv, mid, 1);
if (cc && check_cfunc(vm_cc_cme(cc), rb_obj_equal)) {
- if (recv == obj) {
- return Qtrue;
- }
- else {
- return Qfalse;
- }
+ return RBOOL(recv == obj);
}
else {
return Qundef;
@@ -2143,28 +2123,28 @@ static inline VALUE
double_cmp_lt(double a, double b)
{
CHECK_CMP_NAN(a, b);
- return a < b ? Qtrue : Qfalse;
+ return RBOOL(a < b);
}
static inline VALUE
double_cmp_le(double a, double b)
{
CHECK_CMP_NAN(a, b);
- return a <= b ? Qtrue : Qfalse;
+ return RBOOL(a <= b);
}
static inline VALUE
double_cmp_gt(double a, double b)
{
CHECK_CMP_NAN(a, b);
- return a > b ? Qtrue : Qfalse;
+ return RBOOL(a > b);
}
static inline VALUE
double_cmp_ge(double a, double b)
{
CHECK_CMP_NAN(a, b);
- return a >= b ? Qtrue : Qfalse;
+ return RBOOL(a >= b);
}
static inline VALUE *
@@ -4965,11 +4945,11 @@ vm_opt_lt(VALUE recv, VALUE obj)
{
if (FIXNUM_2_P(recv, obj) &&
BASIC_OP_UNREDEFINED_P(BOP_LT, INTEGER_REDEFINED_OP_FLAG)) {
- return (SIGNED_VALUE)recv < (SIGNED_VALUE)obj ? Qtrue : Qfalse;
+ return RBOOL((SIGNED_VALUE)recv < (SIGNED_VALUE)obj);
}
else if (FLONUM_2_P(recv, obj) &&
BASIC_OP_UNREDEFINED_P(BOP_LT, FLOAT_REDEFINED_OP_FLAG)) {
- return RFLOAT_VALUE(recv) < RFLOAT_VALUE(obj) ? Qtrue : Qfalse;
+ return RBOOL(RFLOAT_VALUE(recv) < RFLOAT_VALUE(obj));
}
else if (SPECIAL_CONST_P(recv) || SPECIAL_CONST_P(obj)) {
return Qundef;
@@ -4978,7 +4958,7 @@ vm_opt_lt(VALUE recv, VALUE obj)
RBASIC_CLASS(obj) == rb_cFloat &&
BASIC_OP_UNREDEFINED_P(BOP_LT, FLOAT_REDEFINED_OP_FLAG)) {
CHECK_CMP_NAN(RFLOAT_VALUE(recv), RFLOAT_VALUE(obj));
- return RFLOAT_VALUE(recv) < RFLOAT_VALUE(obj) ? Qtrue : Qfalse;
+ return RBOOL(RFLOAT_VALUE(recv) < RFLOAT_VALUE(obj));
}
else {
return Qundef;
@@ -4990,11 +4970,11 @@ vm_opt_le(VALUE recv, VALUE obj)
{
if (FIXNUM_2_P(recv, obj) &&
BASIC_OP_UNREDEFINED_P(BOP_LE, INTEGER_REDEFINED_OP_FLAG)) {
- return (SIGNED_VALUE)recv <= (SIGNED_VALUE)obj ? Qtrue : Qfalse;
+ return RBOOL((SIGNED_VALUE)recv <= (SIGNED_VALUE)obj);
}
else if (FLONUM_2_P(recv, obj) &&
BASIC_OP_UNREDEFINED_P(BOP_LE, FLOAT_REDEFINED_OP_FLAG)) {
- return RFLOAT_VALUE(recv) <= RFLOAT_VALUE(obj) ? Qtrue : Qfalse;
+ return RBOOL(RFLOAT_VALUE(recv) <= RFLOAT_VALUE(obj));
}
else if (SPECIAL_CONST_P(recv) || SPECIAL_CONST_P(obj)) {
return Qundef;
@@ -5003,7 +4983,7 @@ vm_opt_le(VALUE recv, VALUE obj)
RBASIC_CLASS(obj) == rb_cFloat &&
BASIC_OP_UNREDEFINED_P(BOP_LE, FLOAT_REDEFINED_OP_FLAG)) {
CHECK_CMP_NAN(RFLOAT_VALUE(recv), RFLOAT_VALUE(obj));
- return RFLOAT_VALUE(recv) <= RFLOAT_VALUE(obj) ? Qtrue : Qfalse;
+ return RBOOL(RFLOAT_VALUE(recv) <= RFLOAT_VALUE(obj));
}
else {
return Qundef;
@@ -5015,11 +4995,11 @@ vm_opt_gt(VALUE recv, VALUE obj)
{
if (FIXNUM_2_P(recv, obj) &&
BASIC_OP_UNREDEFINED_P(BOP_GT, INTEGER_REDEFINED_OP_FLAG)) {
- return (SIGNED_VALUE)recv > (SIGNED_VALUE)obj ? Qtrue : Qfalse;
+ return RBOOL((SIGNED_VALUE)recv > (SIGNED_VALUE)obj);
}
else if (FLONUM_2_P(recv, obj) &&
BASIC_OP_UNREDEFINED_P(BOP_GT, FLOAT_REDEFINED_OP_FLAG)) {
- return RFLOAT_VALUE(recv) > RFLOAT_VALUE(obj) ? Qtrue : Qfalse;
+ return RBOOL(RFLOAT_VALUE(recv) > RFLOAT_VALUE(obj));
}
else if (SPECIAL_CONST_P(recv) || SPECIAL_CONST_P(obj)) {
return Qundef;
@@ -5028,7 +5008,7 @@ vm_opt_gt(VALUE recv, VALUE obj)
RBASIC_CLASS(obj) == rb_cFloat &&
BASIC_OP_UNREDEFINED_P(BOP_GT, FLOAT_REDEFINED_OP_FLAG)) {
CHECK_CMP_NAN(RFLOAT_VALUE(recv), RFLOAT_VALUE(obj));
- return RFLOAT_VALUE(recv) > RFLOAT_VALUE(obj) ? Qtrue : Qfalse;
+ return RBOOL(RFLOAT_VALUE(recv) > RFLOAT_VALUE(obj));
}
else {
return Qundef;
@@ -5040,11 +5020,11 @@ vm_opt_ge(VALUE recv, VALUE obj)
{
if (FIXNUM_2_P(recv, obj) &&
BASIC_OP_UNREDEFINED_P(BOP_GE, INTEGER_REDEFINED_OP_FLAG)) {
- return (SIGNED_VALUE)recv >= (SIGNED_VALUE)obj ? Qtrue : Qfalse;
+ return RBOOL((SIGNED_VALUE)recv >= (SIGNED_VALUE)obj);
}
else if (FLONUM_2_P(recv, obj) &&
BASIC_OP_UNREDEFINED_P(BOP_GE, FLOAT_REDEFINED_OP_FLAG)) {
- return RFLOAT_VALUE(recv) >= RFLOAT_VALUE(obj) ? Qtrue : Qfalse;
+ return RBOOL(RFLOAT_VALUE(recv) >= RFLOAT_VALUE(obj));
}
else if (SPECIAL_CONST_P(recv) || SPECIAL_CONST_P(obj)) {
return Qundef;
@@ -5053,7 +5033,7 @@ vm_opt_ge(VALUE recv, VALUE obj)
RBASIC_CLASS(obj) == rb_cFloat &&
BASIC_OP_UNREDEFINED_P(BOP_GE, FLOAT_REDEFINED_OP_FLAG)) {
CHECK_CMP_NAN(RFLOAT_VALUE(recv), RFLOAT_VALUE(obj));
- return RFLOAT_VALUE(recv) >= RFLOAT_VALUE(obj) ? Qtrue : Qfalse;
+ return RBOOL(RFLOAT_VALUE(recv) >= RFLOAT_VALUE(obj));
}
else {
return Qundef;
diff --git a/vm_method.c b/vm_method.c
index 1950fb1f9db..016dba1dbb1 100644
--- a/vm_method.c
+++ b/vm_method.c
@@ -1701,13 +1701,13 @@ static VALUE
rb_mod_method_defined(int argc, VALUE *argv, VALUE mod)
{
rb_method_visibility_t visi = check_definition_visibility(mod, argc, argv);
- return (visi == METHOD_VISI_PUBLIC || visi == METHOD_VISI_PROTECTED) ? Qtrue : Qfalse;
+ return RBOOL(visi == METHOD_VISI_PUBLIC || visi == METHOD_VISI_PROTECTED);
}
static VALUE
check_definition(VALUE mod, int argc, VALUE *argv, rb_method_visibility_t visi)
{
- return (check_definition_visibility(mod, argc, argv) == visi) ? Qtrue : Qfalse;
+ return RBOOL(check_definition_visibility(mod, argc, argv) == visi);
}
/*
@@ -2609,9 +2609,7 @@ obj_respond_to(int argc, VALUE *argv, VALUE obj)
if (ret == Qundef) ret = Qfalse;
return ret;
}
- if (basic_obj_respond_to(ec, obj, id, !RTEST(priv)))
- return Qtrue;
- return Qfalse;
+ return RBOOL(basic_obj_respond_to(ec, obj, id, !RTEST(priv)));
}
/*
diff --git a/vm_trace.c b/vm_trace.c
index 457bdb0cadc..398ca97de31 100644
--- a/vm_trace.c
+++ b/vm_trace.c
@@ -1321,7 +1321,7 @@ tracepoint_enable_m(rb_execution_context_t *ec, VALUE tpval, VALUE target, VALUE
tpval);
}
else {
- return previous_tracing ? Qtrue : Qfalse;
+ return RBOOL(previous_tracing);
}
}
@@ -1343,7 +1343,7 @@ tracepoint_disable_m(rb_execution_context_t *ec, VALUE tpval)
}
else {
rb_tracepoint_disable(tpval);
- return previous_tracing ? Qtrue : Qfalse;
+ return RBOOL(previous_tracing);
}
}
@@ -1351,7 +1351,7 @@ VALUE
rb_tracepoint_enabled_p(VALUE tpval)
{
rb_tp_t *tp = tpptr(tpval);
- return tp->tracing ? Qtrue : Qfalse;
+ return RBOOL(tp->tracing);
}
static VALUE