summaryrefslogtreecommitdiffhomepage
path: root/src/range.c
diff options
context:
space:
mode:
Diffstat (limited to 'src/range.c')
-rw-r--r--src/range.c15
1 files changed, 8 insertions, 7 deletions
diff --git a/src/range.c b/src/range.c
index 34ca79a0d..8308309ef 100644
--- a/src/range.c
+++ b/src/range.c
@@ -199,27 +199,28 @@ r_le(mrb_state *mrb, mrb_value a, mrb_value b)
static int
r_gt(mrb_state *mrb, mrb_value a, mrb_value b)
{
- //int c;
mrb_value r = mrb_funcall(mrb, a, "<=>", 1, b);
/* output :a < b => -1, a = b => 0, a > b => +1 */
- if (mrb_nil_p(r)) return FALSE;
+ if (mrb_type(r) == MRB_TT_FIXNUM) {
+ int c = mrb_fixnum(r);
+ if (c == 1) return TRUE;
+ }
- if (mrb_obj_equal(mrb, r, mrb_fixnum_value(1))) return TRUE;
return FALSE;
}
static int
r_ge(mrb_state *mrb, mrb_value a, mrb_value b)
{
- //int c;
mrb_value r = mrb_funcall(mrb, a, "<=>", 1, b); /* compare result */
/* output :a < b => -1, a = b => 0, a > b => +1 */
- if (mrb_nil_p(r)) return FALSE;
+ if (mrb_type(r) == MRB_TT_FIXNUM) {
+ int c = mrb_fixnum(r);
+ if (c == 0 || c == 1) return TRUE;
+ }
- if (mrb_obj_equal(mrb, r, mrb_fixnum_value(0))) return TRUE;
- if (mrb_obj_equal(mrb, r, mrb_fixnum_value(1))) return TRUE;
return FALSE;
}