object.c: move string to float conversion to `mrb_f_float`.

parent 66a099b1
...@@ -187,6 +187,9 @@ mrb_f_float(mrb_state *mrb, mrb_value self) ...@@ -187,6 +187,9 @@ mrb_f_float(mrb_state *mrb, mrb_value self)
{ {
mrb_value arg = mrb_get_arg1(mrb); mrb_value arg = mrb_get_arg1(mrb);
if (mrb_string_p(arg)) {
return mrb_float_value(mrb, mrb_str_to_dbl(mrb, arg, TRUE));
}
return mrb_to_float(mrb, arg); return mrb_to_float(mrb, arg);
} }
#endif #endif
......
...@@ -512,9 +512,6 @@ mrb_ensure_float_type(mrb_state *mrb, mrb_value val) ...@@ -512,9 +512,6 @@ mrb_ensure_float_type(mrb_state *mrb, mrb_value val)
case MRB_TT_FLOAT: case MRB_TT_FLOAT:
return val; return val;
case MRB_TT_STRING:
return mrb_float_value(mrb, mrb_str_to_dbl(mrb, val, TRUE));
default: default:
mrb_raisef(mrb, E_TYPE_ERROR, "%Y cannot be converted to Float", val); mrb_raisef(mrb, E_TYPE_ERROR, "%Y cannot be converted to Float", val);
/* not reached */ /* not reached */
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment