refactor code to call mrb_inspect() instead

mrb_inspect() also calls mrb_obj_as_string() after #inspect to ensure
the mrb_value is a string.
This commit is contained in:
cremno
2015-06-13 14:59:57 +02:00
parent d2433a7723
commit 5e8d2a4b84
2 changed files with 2 additions and 10 deletions
+1 -5
View File
@@ -11,12 +11,8 @@
static void
p(mrb_state *mrb, mrb_value obj)
{
mrb_value val;
mrb_value val = mrb_inspect(mrb, obj);
val = mrb_funcall(mrb, obj, "inspect", 0);
if (!mrb_string_p(val)) {
val = mrb_obj_as_string(mrb, obj);
}
fwrite(RSTRING_PTR(val), RSTRING_LEN(val), 1, stdout);
putc('\n', stdout);
}
+1 -5
View File
@@ -27,12 +27,8 @@ MRB_API void
mrb_p(mrb_state *mrb, mrb_value obj)
{
#ifdef ENABLE_STDIO
mrb_value val;
mrb_value val = mrb_inspect(mrb, obj);
val = mrb_funcall(mrb, obj, "inspect", 0);
if (!mrb_string_p(val)) {
val = mrb_obj_as_string(mrb, obj);
}
printstr(mrb, val);
putc('\n', stdout);
#endif