@@ -1023,14 +1023,6 @@ set_join(mrb_state *mrb, mrb_value self)
10231023return mrb_str_new_lit(mrb, "");
10241024 }
102510251026-/* Get separator string */
1027-const char *sep_ptr = "";
1028-mrb_int sep_len = 0;
1029-if (!mrb_nil_p(separator)) {
1030-sep_ptr = RSTRING_PTR(separator);
1031-sep_len = RSTRING_LEN(separator);
1032- }
1033-10341026/* Create result string */
10351027mrb_value result = mrb_str_new_capa(mrb, 64); /* Initial capacity */
10361028mrb_bool first = TRUE;
@@ -1039,7 +1031,9 @@ set_join(mrb_state *mrb, mrb_value self)
10391031int ai = mrb_gc_arena_save(mrb);
10401032KSET_FOREACH(set, k) {
10411033if (!first) {
1042-mrb_str_cat(mrb, result, sep_ptr, sep_len);
1034+if (!mrb_nil_p(separator)) {
1035+mrb_str_cat(mrb, result, RSTRING_PTR(separator), RSTRING_LEN(separator));
1036+ }
10431037 }
10441038else {
10451039first = FALSE;