summaryrefslogtreecommitdiff
path: root/ext/bigdecimal
diff options
context:
space:
mode:
authorKenta Murata <mrkn@mrkn.jp>2020-12-28 22:44:50 +0900
committerKenta Murata <mrkn@mrkn.jp>2020-12-29 12:54:39 +0900
commitd11b78f9c420f39ee800b9feed4839cd28f4ff5c (patch)
tree7535b38e177baf4f07f473c65c2b650c3d406fe8 /ext/bigdecimal
parent06b44f819eb7b5ede1ff69cecb25682b56a1d60c (diff)
[ruby/bigdecimal] Reduce needless object allocation in f_BigDecimal
https://github.com/ruby/bigdecimal/commit/5c808eeabb
Diffstat (limited to 'ext/bigdecimal')
-rw-r--r--ext/bigdecimal/bigdecimal.c8
1 files changed, 3 insertions, 5 deletions
diff --git a/ext/bigdecimal/bigdecimal.c b/ext/bigdecimal/bigdecimal.c
index e544bc7..f89a66e 100644
--- a/ext/bigdecimal/bigdecimal.c
+++ b/ext/bigdecimal/bigdecimal.c
@@ -2870,19 +2870,17 @@ f_BigDecimal(int argc, VALUE *argv, VALUE self)
{
ENTER(1);
Real *pv;
- VALUE obj;
if (argc > 0 && CLASS_OF(argv[0]) == rb_cBigDecimal) {
if (argc == 1 || (argc == 2 && RB_TYPE_P(argv[1], T_HASH))) return argv[0];
}
- obj = TypedData_Wrap_Struct(rb_cBigDecimal, &BigDecimal_data_type, 0);
pv = VpNewVarArg(argc, argv);
if (pv == NULL) return Qnil;
SAVE(pv);
if (ToValue(pv)) pv = VpCopy(NULL, pv);
- RTYPEDDATA_DATA(obj) = pv;
- RB_OBJ_FREEZE(obj);
- return pv->obj = obj;
+ pv->obj = TypedData_Wrap_Struct(rb_cBigDecimal, &BigDecimal_data_type, pv);
+ RB_OBJ_FREEZE(pv->obj);
+ return pv->obj;
}
static VALUE