Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
35 changes: 20 additions & 15 deletions array.c
Original file line number Diff line number Diff line change
Expand Up @@ -2917,23 +2917,28 @@ rb_ary_join(VALUE ary, VALUE sep)
StringValue(sep);
len += RSTRING_LEN(sep) * (RARRAY_LEN(ary) - 1);
}
for (i=0; i<RARRAY_LEN(ary); i++) {
long len_memo = RARRAY_LEN(ary);
for (i=0; i < len_memo; i++) {
val = RARRAY_AREF(ary, i);
tmp = rb_check_string_type(val);

if (NIL_P(tmp) || tmp != val) {
int first;
long n = RARRAY_LEN(ary);
if (i > n) i = n;
result = rb_str_buf_new(len + (n-i)*10);
rb_enc_associate(result, rb_usascii_encoding());
i = ary_join_0(ary, sep, i, result);
first = i == 0;
ary_join_1(ary, ary, sep, i, result, &first);
return result;
if (RB_UNLIKELY(!RB_TYPE_P(val, T_STRING))) {
tmp = rb_check_string_type(val);
if (NIL_P(tmp) || tmp != val) {
int first;
long n = RARRAY_LEN(ary);
if (i > n) i = n;
result = rb_str_buf_new(len + (n-i)*10);
rb_enc_associate(result, rb_usascii_encoding());
i = ary_join_0(ary, sep, i, result);
first = i == 0;
ary_join_1(ary, ary, sep, i, result, &first);
return result;
}
len += RSTRING_LEN(tmp);
len_memo = RARRAY_LEN(ary);
}
else {
len += RSTRING_LEN(val);
}

len += RSTRING_LEN(tmp);
}

result = rb_str_new(0, len);
Expand Down
2 changes: 1 addition & 1 deletion doc/strscan/strscan.md
Original file line number Diff line number Diff line change
Expand Up @@ -417,7 +417,7 @@ Each of these methods returns a captured match value:
| Method | Return After Match | Return After No Match |
|-----------------|-----------------------------------------|-----------------------|
| #size | Count of captured substrings. | +nil+. |
| #[](n) | <tt>n</tt>th captured substring. | +nil+. |
| #\[\](n) | <tt>n</tt>th captured substring. | +nil+. |
| #captures | Array of all captured substrings. | +nil+. |
| #values_at(*n) | Array of specified captured substrings. | +nil+. |
| #named_captures | Hash of named captures. | <tt>{}</tt>. |
Expand Down
Loading