diff options
author | nobu <nobu@b2dd03c8-39d4-4d8f-98ff-823fe69b080e> | 2014-06-12 04:28:16 +0000 |
---|---|---|
committer | nobu <nobu@b2dd03c8-39d4-4d8f-98ff-823fe69b080e> | 2014-06-12 04:28:16 +0000 |
commit | d07a013cf92c866f08433db017a2ffe0615daadd (patch) | |
tree | 6a629fd13f5f9219a4e27195ac09530e5954b80f | |
parent | e2890123acf809aae7999c3f1a31892986e20620 (diff) | |
download | ruby-d07a013cf92c866f08433db017a2ffe0615daadd.tar.gz |
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
-rw-r--r-- | ChangeLog | 5 | ||||
-rw-r--r-- | string.c | 2 |
2 files changed, 7 insertions, 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 @@ -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); } |