string.c: str_shared_replace
* string.c (str_shared_replace): split from rb_str_shared_replace without argument check. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@51352 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
This commit is contained in:
parent
7c413b5545
commit
33f5edd5f3
14
string.c
14
string.c
@ -1105,13 +1105,21 @@ rb_str_to_str(VALUE str)
|
|||||||
}
|
}
|
||||||
|
|
||||||
static inline void str_discard(VALUE str);
|
static inline void str_discard(VALUE str);
|
||||||
|
static void str_shared_replace(VALUE str, VALUE str2);
|
||||||
|
|
||||||
void
|
void
|
||||||
rb_str_shared_replace(VALUE str, VALUE str2)
|
rb_str_shared_replace(VALUE str, VALUE str2)
|
||||||
|
{
|
||||||
|
if (str != str2) str_shared_replace(str, str2);
|
||||||
|
}
|
||||||
|
|
||||||
|
static void
|
||||||
|
str_shared_replace(VALUE str, VALUE str2)
|
||||||
{
|
{
|
||||||
rb_encoding *enc;
|
rb_encoding *enc;
|
||||||
int cr;
|
int cr;
|
||||||
if (str == str2) return;
|
|
||||||
|
ASSUME(str2 != str);
|
||||||
enc = STR_ENC_GET(str2);
|
enc = STR_ENC_GET(str2);
|
||||||
cr = ENC_CODERANGE(str2);
|
cr = ENC_CODERANGE(str2);
|
||||||
str_discard(str);
|
str_discard(str);
|
||||||
@ -4477,7 +4485,7 @@ str_gsub(int argc, VALUE *argv, VALUE str, int bang)
|
|||||||
}
|
}
|
||||||
rb_pat_search(pat, str, last, 1);
|
rb_pat_search(pat, str, last, 1);
|
||||||
if (bang) {
|
if (bang) {
|
||||||
rb_str_shared_replace(str, dest);
|
str_shared_replace(str, dest);
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
RBASIC_SET_CLASS(dest, rb_obj_class(str));
|
RBASIC_SET_CLASS(dest, rb_obj_class(str));
|
||||||
@ -4872,7 +4880,7 @@ rb_str_reverse_bang(VALUE str)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
rb_str_shared_replace(str, rb_str_reverse(str));
|
str_shared_replace(str, rb_str_reverse(str));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
|
Loading…
x
Reference in New Issue
Block a user