Skip to content

Commit

Permalink
Add rb_cstr_convert_to_BigDecimal
Browse files Browse the repository at this point in the history
  • Loading branch information
mrkn committed Jan 12, 2021
1 parent 2dad4d1 commit ac230a9
Showing 1 changed file with 8 additions and 2 deletions.
10 changes: 8 additions & 2 deletions ext/bigdecimal/bigdecimal.c
Original file line number Diff line number Diff line change
Expand Up @@ -2842,18 +2842,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)
{
Expand Down

0 comments on commit ac230a9

Please sign in to comment.