mirror of
https://github.com/ruby/ruby.git
synced 2022-11-09 12:17:21 -05:00
string.c: GC guard
* string.c (rb_str_sub{seq,pos,str}, rb_str_each_{line,codepoint}): prevent String copies from GC. [ruby-core:47881] [Bug #7135] git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@37143 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
This commit is contained in:
parent
104d173752
commit
e808b2b18f
2 changed files with 10 additions and 0 deletions
|
@ -1,3 +1,8 @@
|
|||
Thu Oct 11 23:09:46 2012 Nobuyoshi Nakada <nobu@ruby-lang.org>
|
||||
|
||||
* string.c (rb_str_sub{seq,pos,str}, rb_str_each_{line,codepoint}):
|
||||
prevent String copies from GC. [ruby-core:47881] [Bug #7135]
|
||||
|
||||
Thu Oct 11 07:40:50 2012 NARUSE, Yui <naruse@ruby-lang.org>
|
||||
|
||||
* iseq.c (insn_operand_intern): cast op to rb_call_info_t* before
|
||||
|
|
5
string.c
5
string.c
|
@ -1632,6 +1632,7 @@ rb_str_subseq(VALUE str, long beg, long len)
|
|||
}
|
||||
else {
|
||||
str2 = rb_str_new5(str, RSTRING_PTR(str)+beg, len);
|
||||
RB_GC_GUARD(str);
|
||||
}
|
||||
|
||||
rb_enc_cr_str_copy_for_substr(str2, str);
|
||||
|
@ -1721,6 +1722,7 @@ rb_str_subpos(VALUE str, long beg, long *lenp)
|
|||
}
|
||||
end:
|
||||
*lenp = len;
|
||||
RB_GC_GUARD(str);
|
||||
return p;
|
||||
}
|
||||
|
||||
|
@ -1741,6 +1743,7 @@ rb_str_substr(VALUE str, long beg, long len)
|
|||
str2 = rb_str_new5(str, p, len);
|
||||
rb_enc_cr_str_copy_for_substr(str2, str);
|
||||
OBJ_INFECT(str2, str);
|
||||
RB_GC_GUARD(str);
|
||||
}
|
||||
|
||||
return str2;
|
||||
|
@ -6206,6 +6209,7 @@ rb_str_each_line(int argc, VALUE *argv, VALUE str)
|
|||
OBJ_INFECT(line, str);
|
||||
rb_enc_cr_str_copy_for_substr(line, str);
|
||||
rb_yield(line);
|
||||
RB_GC_GUARD(str);
|
||||
}
|
||||
|
||||
return orig;
|
||||
|
@ -6332,6 +6336,7 @@ rb_str_each_codepoint(VALUE str)
|
|||
rb_yield(UINT2NUM(c));
|
||||
ptr += n;
|
||||
}
|
||||
RB_GC_GUARD(str);
|
||||
return orig;
|
||||
}
|
||||
|
||||
|
|
Loading…
Add table
Reference in a new issue