summaryrefslogtreecommitdiff
path: root/object.c
diff options
context:
space:
mode:
Diffstat (limited to 'object.c')
-rw-r--r--object.c10
1 files changed, 8 insertions, 2 deletions
diff --git a/object.c b/object.c
index 7970c51171..dc8c3bb3b4 100644
--- a/object.c
+++ b/object.c
@@ -1940,7 +1940,10 @@ rb_check_convert_type(VALUE val, int type, const char *tname, const char *method
static VALUE
rb_to_integer(VALUE val, const char *method)
{
- VALUE v = convert_type(val, "Integer", method, Qtrue);
+ VALUE v;
+
+ if (FIXNUM_P(val)) return val;
+ v = convert_type(val, "Integer", method, Qtrue);
if (!rb_obj_is_kind_of(v, rb_cInteger)) {
char *cname = rb_obj_classname(val);
rb_raise(rb_eTypeError, "can't convert %s to Integer (%s#%s gives %s)",
@@ -1952,7 +1955,10 @@ rb_to_integer(VALUE val, const char *method)
VALUE
rb_check_to_integer(VALUE val, const char *method)
{
- VALUE v = convert_type(val, "Integer", method, Qfalse);
+ VALUE v;
+
+ if (FIXNUM_P(val)) return val;
+ v = convert_type(val, "Integer", method, Qfalse);
if (!rb_obj_is_kind_of(v, rb_cInteger)) {
return Qnil;
}