string.c: shrink before freezing

* string.c (rb_str_freeze): shrink the buffer before freezing, as
  pointed out by Eric Wong at [ruby-core:63119].

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@46411 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
This commit is contained in:
nobu 2014-06-12 04:28:16 +00:00
parent e2890123ac
commit d07a013cf9
2 changed files with 7 additions and 0 deletions

View File

@ -1,3 +1,8 @@
Thu Jun 12 13:27:38 2014 Nobuyoshi Nakada <nobu@ruby-lang.org>
* string.c (rb_str_freeze): shrink the buffer before freezing, as
pointed out by Eric Wong at [ruby-core:63119].
Thu Jun 12 13:09:03 2014 Nobuyoshi Nakada <nobu@ruby-lang.org>
* file.c (expand_path): shrink expanded path which no longer needs

View File

@ -1905,6 +1905,8 @@ rb_str_substr(VALUE str, long beg, long len)
VALUE
rb_str_freeze(VALUE str)
{
if (OBJ_FROZEN(str)) return str;
rb_str_resize(str, RSTRING_LEN(str));
return rb_obj_freeze(str);
}