Need not to call mrb_obj_as_string() is sep is nil.

This commit is contained in:
Yukihiro "Matz" Matsumoto
2017-03-18 22:38:45 +09:00
parent ce8697523f
commit 6db38c3768
+3 -1
View File
@@ -1071,7 +1071,9 @@ join_ary(mrb_state *mrb, mrb_value ary, mrb_value sep, mrb_value list)
MRB_API mrb_value
mrb_ary_join(mrb_state *mrb, mrb_value ary, mrb_value sep)
{
sep = mrb_obj_as_string(mrb, sep);
if (!mrb_nil_p(sep)) {
sep = mrb_obj_as_string(mrb, sep);
}
return join_ary(mrb, ary, sep, mrb_ary_new(mrb));
}