Need not to call mrb_obj_as_string() is sep is nil.
MODIFY
src/array.c
src/array.c
@@ -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)
{
+ if (!mrb_nil_p(sep)) {
sep = mrb_obj_as_string(mrb, sep);
+ }
return join_ary(mrb, ary, sep, mrb_ary_new(mrb));
}

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