mirror of
https://github.com/ruby/ruby.git
synced 2022-11-09 12:17:21 -05:00
Use RB_INTEGER_TYPE_P instead of rb_obj_is_kind_of
For checking whether an object is an Integer, because a subclass of Integer is meaningless in Ruby, RB_INTEGER_TYPE_P is better than rb_obj_is_kind_of for speed. * object.c (rb_to_integer): Use RB_INTEGER_TYPE_P instead of rb_obj_is_kind_of. * object.c (rb_check_to_integer): ditto. * range.c (range_max): ditto. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@62582 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
This commit is contained in:
parent
cc4be225a8
commit
2234edf0b1
2 changed files with 24 additions and 24 deletions
4
object.c
4
object.c
|
@ -3043,7 +3043,7 @@ rb_to_integer(VALUE val, const char *method)
|
|||
if (FIXNUM_P(val)) return val;
|
||||
if (RB_TYPE_P(val, T_BIGNUM)) return val;
|
||||
v = convert_type(val, "Integer", method, TRUE);
|
||||
if (!rb_obj_is_kind_of(v, rb_cInteger)) {
|
||||
if (!RB_INTEGER_TYPE_P(v)) {
|
||||
conversion_mismatch(val, "Integer", method, v);
|
||||
}
|
||||
return v;
|
||||
|
@ -3067,7 +3067,7 @@ rb_check_to_integer(VALUE val, const char *method)
|
|||
if (FIXNUM_P(val)) return val;
|
||||
if (RB_TYPE_P(val, T_BIGNUM)) return val;
|
||||
v = convert_type(val, "Integer", method, FALSE);
|
||||
if (!rb_obj_is_kind_of(v, rb_cInteger)) {
|
||||
if (!RB_INTEGER_TYPE_P(v)) {
|
||||
return Qnil;
|
||||
}
|
||||
return v;
|
||||
|
|
4
range.c
4
range.c
|
@ -959,11 +959,11 @@ range_max(int argc, VALUE *argv, VALUE range)
|
|||
if (c > 0)
|
||||
return Qnil;
|
||||
if (EXCL(range)) {
|
||||
if (!FIXNUM_P(e) && !rb_obj_is_kind_of(e, rb_cInteger)) {
|
||||
if (!RB_INTEGER_TYPE_P(e)) {
|
||||
rb_raise(rb_eTypeError, "cannot exclude non Integer end value");
|
||||
}
|
||||
if (c == 0) return Qnil;
|
||||
if (!FIXNUM_P(b) && !rb_obj_is_kind_of(b,rb_cInteger)) {
|
||||
if (!RB_INTEGER_TYPE_P(b)) {
|
||||
rb_raise(rb_eTypeError, "cannot exclude end value with non Integer begin value");
|
||||
}
|
||||
if (FIXNUM_P(e)) {
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue