GitHub

@@ -1023,14 +1023,6 @@ set_join(mrb_state *mrb, mrb_value self)

10231023

return 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 */

10351027

mrb_value result = mrb_str_new_capa(mrb, 64); /* Initial capacity */

10361028

mrb_bool first = TRUE;

@@ -1039,7 +1031,9 @@ set_join(mrb_state *mrb, mrb_value self)

10391031

int ai = mrb_gc_arena_save(mrb);

10401032

KSET_FOREACH(set, k) {

10411033

if (!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

}

10441038

else {

10451039

first = FALSE;

Read the original on github.com ↗