summaryrefslogtreecommitdiff
path: root/ext/bigdecimal
diff options
context:
space:
mode:
authorKenta Murata <mrkn@mrkn.jp>2021-01-12 09:19:14 +0900
committerKenta Murata <mrkn@mrkn.jp>2021-01-12 09:21:58 +0900
commit78d3813c74c3dd37eb3a7d5fa2fb096566c0b290 (patch)
tree67c6bf6913c3065b263b35721ce2dc1f11d7992d /ext/bigdecimal
parent66a844fd07ca0fd652a20a1973ea242422d4ae6d (diff)
[ruby/bigdecimal] Add rb_cstr_convert_to_BigDecimal
https://github.com/ruby/bigdecimal/commit/ac230a996e
Diffstat (limited to 'ext/bigdecimal')
-rw-r--r--ext/bigdecimal/bigdecimal.c10
1 files changed, 8 insertions, 2 deletions
diff --git a/ext/bigdecimal/bigdecimal.c b/ext/bigdecimal/bigdecimal.c
index 3432aa2..02879a9 100644
--- a/ext/bigdecimal/bigdecimal.c
+++ b/ext/bigdecimal/bigdecimal.c
@@ -2839,18 +2839,24 @@ rb_rational_convert_to_BigDecimal(VALUE val, size_t digs, int raise_exception)
}
static VALUE
-rb_str_convert_to_BigDecimal(VALUE val, size_t digs, int raise_exception)
+rb_cstr_convert_to_BigDecimal(const char *c_str, size_t digs, int raise_exception)
{
if (digs == SIZE_MAX)
digs = 0;
- const char *c_str = StringValueCStr(val);
Real *vp = VpCreateRbObject(digs, c_str, raise_exception);
if (!vp)
return Qnil;
return VpCheckGetValue(vp);
}
+static inline VALUE
+rb_str_convert_to_BigDecimal(VALUE val, size_t digs, int raise_exception)
+{
+ const char *c_str = StringValueCStr(val);
+ return rb_cstr_convert_to_BigDecimal(c_str, digs, raise_exception);
+}
+
static VALUE
rb_convert_to_BigDecimal(VALUE val, size_t digs, int raise_exception)
{