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

ruby-changes:64675

From: Kenta <ko1@a...>
Date: Thu, 31 Dec 2020 02:19:54 +0900 (JST)
Subject: [ruby-changes:64675] 4569e46550 (master): [ruby/bigdecimal] Remove ToValue

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

From 4569e46550d4ceea2ee4d5c683dd27872a758b36 Mon Sep 17 00:00:00 2001
From: Kenta Murata <mrkn@m...>
Date: Thu, 31 Dec 2020 01:43:08 +0900
Subject: [ruby/bigdecimal] Remove ToValue

https://github.com/ruby/bigdecimal/commit/97e9feeebd

diff --git a/ext/bigdecimal/bigdecimal.c b/ext/bigdecimal/bigdecimal.c
index 888b21f..13b2cdc 100644
--- a/ext/bigdecimal/bigdecimal.c
+++ b/ext/bigdecimal/bigdecimal.c
@@ -229,8 +229,6 @@ VpCheckGetValue(Real *p) https://github.com/ruby/ruby/blob/trunk/ext/bigdecimal/bigdecimal.c#L229
     return p->obj;
 }
 
-#define ToValue(p) VpCheckGetValue(p)
-
 NORETURN(static void cannot_be_coerced_into_BigDecimal(VALUE, VALUE));
 
 static void
@@ -289,7 +287,7 @@ again: https://github.com/ruby/ruby/blob/trunk/ext/bigdecimal/bigdecimal.c#L287
 	    pv = GetVpValueWithPrec(num, -1, must);
 	    if (pv == NULL) goto SomeOneMayDoIt;
 
-	    v = BigDecimal_div2(ToValue(pv), rb_rational_den(v), LONG2NUM(prec));
+            v = BigDecimal_div2(VpCheckGetValue(pv), rb_rational_den(v), LONG2NUM(prec));
 	    goto again;
 	}
 
@@ -566,7 +564,7 @@ BigDecimal_load(VALUE self, VALUE str) https://github.com/ruby/ruby/blob/trunk/ext/bigdecimal/bigdecimal.c#L564
     if (m && pv->MaxPrec > m) {
 	pv->MaxPrec = m+1;
     }
-    return ToValue(pv);
+    return VpCheckGetValue(pv);
 }
 
 static unsigned short
@@ -1004,7 +1002,7 @@ BigDecimal_coerce(VALUE self, VALUE other) https://github.com/ruby/ruby/blob/trunk/ext/bigdecimal/bigdecimal.c#L1002
 
     if (RB_TYPE_P(other, T_FLOAT)) {
 	GUARD_OBJ(b, GetVpValueWithPrec(other, DBLE_FIG, 1));
-	obj = rb_assoc_new(ToValue(b), self);
+        obj = rb_assoc_new(VpCheckGetValue(b), self);
     }
     else {
 	if (RB_TYPE_P(other, T_RATIONAL)) {
@@ -1090,7 +1088,7 @@ BigDecimal_add(VALUE self, VALUE r) https://github.com/ruby/ruby/blob/trunk/ext/bigdecimal/bigdecimal.c#L1088
 	    VpAddSub(c, a, b, 1);
 	}
     }
-    return ToValue(c);
+    return VpCheckGetValue(c);
 }
 
  /* call-seq:
@@ -1148,7 +1146,7 @@ BigDecimal_sub(VALUE self, VALUE r) https://github.com/ruby/ruby/blob/trunk/ext/bigdecimal/bigdecimal.c#L1146
 	    VpAddSub(c, a, b, -1);
 	}
     }
-    return ToValue(c);
+    return VpCheckGetValue(c);
 }
 
 static VALUE
@@ -1355,7 +1353,7 @@ BigDecimal_neg(VALUE self) https://github.com/ruby/ruby/blob/trunk/ext/bigdecimal/bigdecimal.c#L1353
     GUARD_OBJ(a, GetVpValue(self, 1));
     GUARD_OBJ(c, VpCreateRbObject(a->Prec *(VpBaseFig() + 1), "0"));
     VpAsgn(c, a, -1);
-    return ToValue(c);
+    return VpCheckGetValue(c);
 }
 
  /*
@@ -1397,7 +1395,7 @@ BigDecimal_mult(VALUE self, VALUE r) https://github.com/ruby/ruby/blob/trunk/ext/bigdecimal/bigdecimal.c#L1395
     mx = a->Prec + b->Prec;
     GUARD_OBJ(c, VpCreateRbObject(mx *(VpBaseFig() + 1), "0"));
     VpMult(c, a, b);
-    return ToValue(c);
+    return VpCheckGetValue(c);
 }
 
 static VALUE
@@ -1459,7 +1457,7 @@ BigDecimal_div(VALUE self, VALUE r) https://github.com/ruby/ruby/blob/trunk/ext/bigdecimal/bigdecimal.c#L1457
     if (VpHasVal(div)) { /* frac[0] must be zero for NaN,INF,Zero */
 	VpInternalRound(c, 0, c->frac[c->Prec-1], (BDIGIT)(VpBaseVal() * (BDIGIT_DBL)res->frac[0] / div->frac[0]));
     }
-    return ToValue(c);
+    return VpCheckGetValue(c);
 }
 
 /*
@@ -1562,7 +1560,7 @@ BigDecimal_mod(VALUE self, VALUE r) /* %: a%b = a - (a.to_f/b).floor * b */ https://github.com/ruby/ruby/blob/trunk/ext/bigdecimal/bigdecimal.c#L1560
 
     if (BigDecimal_DoDivmod(self, r, &div, &mod)) {
 	SAVE(div); SAVE(mod);
-	return ToValue(mod);
+        return VpCheckGetValue(mod);
     }
     return DoSomeOne(self, r, '%');
 }
@@ -1627,7 +1625,7 @@ BigDecimal_remainder(VALUE self, VALUE r) /* remainder */ https://github.com/ruby/ruby/blob/trunk/ext/bigdecimal/bigdecimal.c#L1625
     Real  *d, *rv = 0;
     f = BigDecimal_divremain(self, r, &d, &rv);
     if (!NIL_P(f)) return f;
-    return ToValue(rv);
+    return VpCheckGetValue(rv);
 }
 
 /* call-seq:
@@ -1660,7 +1658,7 @@ BigDecimal_divmod(VALUE self, VALUE r) https://github.com/ruby/ruby/blob/trunk/ext/bigdecimal/bigdecimal.c#L1658
 
     if (BigDecimal_DoDivmod(self, r, &div, &mod)) {
 	SAVE(div); SAVE(mod);
-	return rb_assoc_new(ToValue(div), ToValue(mod));
+        return rb_assoc_new(VpCheckGetValue(div), VpCheckGetValue(mod));
     }
     return DoSomeOne(self,r,rb_intern("divmod"));
 }
@@ -1678,7 +1676,7 @@ BigDecimal_div2(VALUE self, VALUE b, VALUE n) https://github.com/ruby/ruby/blob/trunk/ext/bigdecimal/bigdecimal.c#L1676
         Real *div = NULL;
         Real *mod;
         if (BigDecimal_DoDivmod(self, b, &div, &mod)) {
-            return BigDecimal_to_i(ToValue(div));
+            return BigDecimal_to_i(VpCheckGetValue(div));
         }
         return DoSomeOne(self, b, rb_intern("div"));
     }
@@ -1703,7 +1701,7 @@ BigDecimal_div2(VALUE self, VALUE b, VALUE n) https://github.com/ruby/ruby/blob/trunk/ext/bigdecimal/bigdecimal.c#L1701
         VpDivd(cv, res, av, bv);
         VpSetPrecLimit(pl);
         VpLeftRound(cv, VpGetRoundMode(), ix);
-        return ToValue(cv);
+        return VpCheckGetValue(cv);
     }
 }
 
@@ -1761,7 +1759,7 @@ BigDecimal_add2(VALUE self, VALUE b, VALUE n) https://github.com/ruby/ruby/blob/trunk/ext/bigdecimal/bigdecimal.c#L1759
 	VpSetPrecLimit(pl);
 	GUARD_OBJ(cv, GetVpValue(c, 1));
 	VpLeftRound(cv, VpGetRoundMode(), mx);
-	return ToValue(cv);
+        return VpCheckGetValue(cv);
     }
 }
 
@@ -1791,7 +1789,7 @@ BigDecimal_sub2(VALUE self, VALUE b, VALUE n) https://github.com/ruby/ruby/blob/trunk/ext/bigdecimal/bigdecimal.c#L1789
 	VpSetPrecLimit(pl);
 	GUARD_OBJ(cv, GetVpValue(c, 1));
 	VpLeftRound(cv, VpGetRoundMode(), mx);
-	return ToValue(cv);
+        return VpCheckGetValue(cv);
     }
 }
 
@@ -1809,7 +1807,7 @@ BigDecimal_mult2(VALUE self, VALUE b, VALUE n) https://github.com/ruby/ruby/blob/trunk/ext/bigdecimal/bigdecimal.c#L1807
 	VpSetPrecLimit(pl);
 	GUARD_OBJ(cv, GetVpValue(c, 1));
 	VpLeftRound(cv, VpGetRoundMode(), mx);
-	return ToValue(cv);
+        return VpCheckGetValue(cv);
     }
 }
 
@@ -1835,7 +1833,7 @@ BigDecimal_abs(VALUE self) https://github.com/ruby/ruby/blob/trunk/ext/bigdecimal/bigdecimal.c#L1833
     GUARD_OBJ(c, VpCreateRbObject(mx, "0"));
     VpAsgn(c, a, 1);
     VpChangeSign(c, 1);
-    return ToValue(c);
+    return VpCheckGetValue(c);
 }
 
 /* call-seq:
@@ -1859,7 +1857,7 @@ BigDecimal_sqrt(VALUE self, VALUE nFig) https://github.com/ruby/ruby/blob/trunk/ext/bigdecimal/bigdecimal.c#L1857
     if (mx <= n) mx = n;
     GUARD_OBJ(c, VpCreateRbObject(mx, "0"));
     VpSqrt(c, a);
-    return ToValue(c);
+    return VpCheckGetValue(c);
 }
 
 /* Return the integer part of the number, as a BigDecimal.
@@ -1875,7 +1873,7 @@ BigDecimal_fix(VALUE self) https://github.com/ruby/ruby/blob/trunk/ext/bigdecimal/bigdecimal.c#L1873
     mx = a->Prec *(VpBaseFig() + 1);
     GUARD_OBJ(c, VpCreateRbObject(mx, "0"));
     VpActiveRound(c, a, VP_ROUND_DOWN, 0); /* 0: round off */
-    return ToValue(c);
+    return VpCheckGetValue(c);
 }
 
 /* call-seq:
@@ -1950,9 +1948,9 @@ BigDecimal_round(int argc, VALUE *argv, VALUE self) https://github.com/ruby/ruby/blob/trunk/ext/bigdecimal/bigdecimal.c#L1948
     VpSetPrecLimit(pl);
     VpActiveRound(c, a, sw, iLoc);
     if (round_to_int) {
-	return BigDecimal_to_i(ToValue(c));
+        return BigDecimal_to_i(VpCheckGetValue(c));
     }
-    return ToValue(c);
+    return VpCheckGetValue(c);
 }
 
 /* call-seq:
@@ -1996,9 +1994,9 @@ BigDecimal_truncate(int argc, VALUE *argv, VALUE self) https://github.com/ruby/ruby/blob/trunk/ext/bigdecimal/bigdecimal.c#L1994
     VpSetPrecLimit(pl);
     VpActiveRound(c, a, VP_ROUND_DOWN, iLoc); /* 0: truncate */
     if (argc == 0) {
-	return BigDecimal_to_i(ToValue(c));
+        return BigDecimal_to_i(VpCheckGetValue(c));
     }
-    return ToValue(c);
+    return VpCheckGetValue(c);
 }
 
 /* Return the fractional part of the number, as a BigDecimal.
@@ -2014,7 +2012,7 @@ BigDecimal_frac(VALUE self) https://github.com/ruby/ruby/blob/trunk/ext/bigdecimal/bigdecimal.c#L2012
     mx = a->Prec * (VpBaseFig() + 1);
     GUARD_OBJ(c, VpCreateRbObject(mx, "0"));
     VpFrac(c, a);
-    return ToValue(c);
+    return VpCheckGetValue(c);
 }
 
 /* call-seq:
@@ -2059,9 +2057,9 @@ BigDecimal_floor(int argc, VALUE *argv, VALUE self) https://github.com/ruby/ruby/blob/trunk/ext/bigdecimal/bigdecimal.c#L2057
     VPrint(stderr, "floor: c=%\n", c);
 #endif
     if (argc == 0) {
-	return BigDecimal_to_i(ToValue(c));
+        return BigDecimal_to_i(VpCheckGetValue(c));
     }
-    return ToValue(c);
+    return VpCheckGetValue(c);
 }
 
 /* call-seq:
@@ -2102,9 +2100,9 @@ BigDecimal_ceil(int argc, VALUE *argv, VALUE self) https://github.com/ruby/ruby/blob/trunk/ext/bigdecimal/bigdecimal.c#L2100
     VpSetPrecLimit(pl);
     VpActiveRound(c, a, VP_ROUND_CEIL, iLoc);
     if (argc == 0) {
-	return BigDecimal_to_i(ToValue(c));
+        return BigDecimal_to_i(VpCheckGetValue(c));
     }
-    return ToValue(c);
+    return VpCheckGetValue(c);
 }
 
 /* call-seq:
@@ -2406,7 +2404,7 @@ rmpd_power_by_big_decimal(Real const* x, Real const* exp, ssize_t const n) https://github.com/ruby/ruby/blob/trunk/ext/bigdecimal/bigdecimal.c#L2404
     volatile VALUE obj = exp->obj;
 
     if (VpIsZero(exp)) {
-	return ToValue(VpCreateRbObject(n, "1"));
+        return VpCheckGetValue(VpCreateRbObject(n, "1"));
     }
 
     log_x = BigMath_log(x->obj, SSIZET2NUM(n+1));
@@ -2447,7 +2445,7 @@ BigDecimal_power(int argc, VALUE*argv, VALUE self) https://github.com/ruby/ruby/blob/trunk/ext/bigdecimal/bigdecimal.c#L2445
 	y = VpCreateRbObject(n, "0");
 	RB_GC_GUARD(y->obj);
 	VpSetNaN(y);
-	return ToValue(y);
+        return VpCheckGetValue(y);
     }
 
   retry:
@@ -2538,18 +2536,18 @@ BigDecimal_power(int argc, VALUE*argv, VALUE self) https://github.com/ruby/ruby/blob/trunk/ext/bigdecimal/bigdecimal.c#L2536
 		/* (+0) ** (-num)  -> Infinity */
 		VpSetPosInf(y);
 	    }
-	    return ToValue(y);
+            return VpCheckGetValue(y);
 	}
 	els (... truncated)

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

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