mirror of
https://github.com/ruby/ruby.git
synced 2022-11-09 12:17:21 -05:00
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:
parent
e2890123ac
commit
d07a013cf9
2 changed files with 7 additions and 0 deletions
|
|
@ -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
|
||||
|
|
|
|||
2
string.c
2
string.c
|
|
@ -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);
|
||||
}
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue