aboutsummaryrefslogtreecommitdiffstats
path: root/object.c
diff options
context:
space:
mode:
Diffstat (limited to 'object.c')
-rw-r--r--object.c17
1 files changed, 15 insertions, 2 deletions
diff --git a/object.c b/object.c
index a1dcf830e7..5f0055fb5a 100644
--- a/object.c
+++ b/object.c
@@ -297,6 +297,19 @@ init_copy(VALUE dest, VALUE obj)
}
}
+static inline int
+special_object_p(VALUE obj)
+{
+ if (SPECIAL_CONST_P(obj)) return TRUE;
+ switch (BUILTIN_TYPE(obj)) {
+ case T_BIGNUM:
+ case T_FLOAT:
+ return TRUE;
+ default:
+ return FALSE;
+ }
+}
+
/*
* call-seq:
* obj.clone(freeze: true) -> an_object
@@ -345,7 +358,7 @@ rb_obj_clone2(int argc, VALUE *argv, VALUE obj)
}
}
- if (rb_special_const_p(obj)) {
+ if (special_object_p(obj)) {
if (kwfreeze == Qfalse)
rb_raise(rb_eArgError, "can't unfreeze %s", rb_obj_classname(obj));
return obj;
@@ -424,7 +437,7 @@ rb_obj_dup(VALUE obj)
{
VALUE dup;
- if (rb_special_const_p(obj)) {
+ if (special_object_p(obj)) {
return obj;
}
dup = rb_obj_alloc(rb_obj_class(obj));