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

ruby-changes:64897

From: Kenta <ko1@a...>
Date: Sat, 16 Jan 2021 00:15:02 +0900 (JST)
Subject: [ruby-changes:64897] f95f85b215 (master): [ruby/bigdecimal] Use new conversion functions in BigDecimal_DoDivmod

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

From f95f85b215d85dfd2c439d1a366bb6419274c7ac Mon Sep 17 00:00:00 2001
From: Kenta Murata <mrkn@m...>
Date: Fri, 15 Jan 2021 10:03:56 +0900
Subject: [ruby/bigdecimal] Use new conversion functions in BigDecimal_DoDivmod

https://github.com/ruby/bigdecimal/commit/68c20200d5

diff --git a/ext/bigdecimal/bigdecimal.c b/ext/bigdecimal/bigdecimal.c
index 2191007..c93ad91 100644
--- a/ext/bigdecimal/bigdecimal.c
+++ b/ext/bigdecimal/bigdecimal.c
@@ -1426,18 +1426,25 @@ BigDecimal_DoDivmod(VALUE self, VALUE r, Real **div, Real **mod) https://github.com/ruby/ruby/blob/trunk/ext/bigdecimal/bigdecimal.c#L1426
     Real *a, *b;
     size_t mx;
 
-    GUARD_OBJ(a, GetVpValue(self, 1));
+    TypedData_Get_Struct(self, Real, &BigDecimal_data_type, a);
+    SAVE(a);
+
+    VALUE rr = Qnil;
     if (RB_TYPE_P(r, T_FLOAT)) {
-	b = GetVpValueWithPrec(r, 0, 1);
+        rr = rb_float_convert_to_BigDecimal(r, 0, true);
     }
     else if (RB_TYPE_P(r, T_RATIONAL)) {
-	b = GetVpValueWithPrec(r, a->Prec*VpBaseFig(), 1);
+        rr = rb_rational_convert_to_BigDecimal(r, a->Prec*BASE_FIG, true);
     }
     else {
-	b = GetVpValue(r, 0);
+        rr = rb_convert_to_BigDecimal(r, 0, false);
     }
 
-    if (!b) return Qfalse;
+    if (!is_kind_of_BigDecimal(rr)) {
+        return Qfalse;
+    }
+
+    TypedData_Get_Struct(rr, Real, &BigDecimal_data_type, b);
     SAVE(b);
 
     if (VpIsNaN(a) || VpIsNaN(b)) goto NaN;
-- 
cgit v0.10.2


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

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