зеркало из https://github.com/github/ruby.git
* string.c (str_new3): embed shorter strings more eagerly.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@10991 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
This commit is contained in:
Родитель
e4800cabfb
Коммит
5b950717b7
|
@ -21,6 +21,10 @@ Thu Sep 21 22:56:20 2006 Nobuyoshi Nakada <nobu@ruby-lang.org>
|
|||
|
||||
* ext/extmk.rb: expand ruby executable names.
|
||||
|
||||
Thu Sep 21 20:19:22 2006 Yukihiro Matsumoto <matz@ruby-lang.org>
|
||||
|
||||
* string.c (str_new3): embed shorter strings more eagerly.
|
||||
|
||||
Thu Sep 21 17:44:49 2006 Yukihiro Matsumoto <matz@ruby-lang.org>
|
||||
|
||||
* string.c (rb_str_startwith): a new method to check if a string
|
||||
|
|
17
string.c
17
string.c
|
@ -191,11 +191,18 @@ str_new3(VALUE klass, VALUE str)
|
|||
{
|
||||
VALUE str2 = str_alloc(klass);
|
||||
|
||||
FL_SET(str2, STR_NOEMBED);
|
||||
RSTRING(str2)->as.heap.len = RSTRING_LEN(str);
|
||||
RSTRING(str2)->as.heap.ptr = RSTRING_PTR(str);
|
||||
RSTRING(str2)->as.heap.aux.shared = str;
|
||||
FL_SET(str2, ELTS_SHARED);
|
||||
if (RSTRING_LEN(str) <= RSTRING_EMBED_LEN_MAX) {
|
||||
STR_SET_EMBED(str);
|
||||
memcpy(RSTRING_PTR(str2), RSTRING_PTR(str), RSTRING_LEN(str)+1);
|
||||
STR_SET_EMBED_LEN(str2, RSTRING_LEN(str));
|
||||
}
|
||||
else {
|
||||
FL_SET(str2, STR_NOEMBED);
|
||||
RSTRING(str2)->as.heap.len = RSTRING_LEN(str);
|
||||
RSTRING(str2)->as.heap.ptr = RSTRING_PTR(str);
|
||||
RSTRING(str2)->as.heap.aux.shared = str;
|
||||
FL_SET(str2, ELTS_SHARED);
|
||||
}
|
||||
OBJ_INFECT(str2, str);
|
||||
|
||||
return str2;
|
||||
|
|
Загрузка…
Ссылка в новой задаче