[前][次][番号順一覧][スレッド一覧]

ruby-changes:64648

From: Kenta <ko1@a...>
Date: Tue, 29 Dec 2020 13:09:19 +0900 (JST)
Subject: [ruby-changes:64648] d11b78f9c4 (master): [ruby/bigdecimal] Reduce needless object allocation in f_BigDecimal

https://git.ruby-lang.org/ruby.git/commit/?id=d11b78f9c4

From d11b78f9c420f39ee800b9feed4839cd28f4ff5c Mon Sep 17 00:00:00 2001
From: Kenta Murata <mrkn@m...>
Date: Mon, 28 Dec 2020 22:44:50 +0900
Subject: [ruby/bigdecimal] Reduce needless object allocation in f_BigDecimal

https://github.com/ruby/bigdecimal/commit/5c808eeabb

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) https://github.com/ruby/ruby/blob/trunk/ext/bigdecimal/bigdecimal.c#L2870
 {
     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
-- 
cgit v0.10.2


--
ML: ruby-changes@q...
Info: http://www.atdot.net/~ko1/quickml/

[前][次][番号順一覧][スレッド一覧]