Skip to content

Commit 5c808ee

Browse files
committed
Reduce needless object allocation in f_BigDecimal
1 parent 905d034 commit 5c808ee

File tree

1 file changed

+3
-5
lines changed

1 file changed

+3
-5
lines changed

ext/bigdecimal/bigdecimal.c

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -2870,19 +2870,17 @@ f_BigDecimal(int argc, VALUE *argv, VALUE self)
28702870
{
28712871
ENTER(1);
28722872
Real *pv;
2873-
VALUE obj;
28742873

28752874
if (argc > 0 && CLASS_OF(argv[0]) == rb_cBigDecimal) {
28762875
if (argc == 1 || (argc == 2 && RB_TYPE_P(argv[1], T_HASH))) return argv[0];
28772876
}
2878-
obj = TypedData_Wrap_Struct(rb_cBigDecimal, &BigDecimal_data_type, 0);
28792877
pv = VpNewVarArg(argc, argv);
28802878
if (pv == NULL) return Qnil;
28812879
SAVE(pv);
28822880
if (ToValue(pv)) pv = VpCopy(NULL, pv);
2883-
RTYPEDDATA_DATA(obj) = pv;
2884-
RB_OBJ_FREEZE(obj);
2885-
return pv->obj = obj;
2881+
pv->obj = TypedData_Wrap_Struct(rb_cBigDecimal, &BigDecimal_data_type, pv);
2882+
RB_OBJ_FREEZE(pv->obj);
2883+
return pv->obj;
28862884
}
28872885

28882886
static VALUE

0 commit comments

Comments
 (0)