From bbf7495fe223c7ab8235bf372c1164ab4e70633b Mon Sep 17 00:00:00 2001 From: normal Date: Mon, 6 Jul 2015 19:45:02 +0000 Subject: string.c: ensure String#freeze resizes internal buffer rb_str_freeze may resize oversized buffers to save memory, so favor it over rb_obj_freeze. This is useful because IO methods do not prematurely shrink buffers, as they are likely to be overwritten with full data. * string.c (Init_String): use rb_str_freeze for String#freeze git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@51170 b2dd03c8-39d4-4d8f-98ff-823fe69b080e --- string.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'string.c') diff --git a/string.c b/string.c index 6ef92eb9fb..03922e56c1 100644 --- a/string.c +++ b/string.c @@ -9150,7 +9150,7 @@ Init_String(void) rb_define_method(rb_cString, "byteslice", rb_str_byteslice, -1); rb_define_method(rb_cString, "scrub", str_scrub, -1); rb_define_method(rb_cString, "scrub!", str_scrub_bang, -1); - rb_define_method(rb_cString, "freeze", rb_obj_freeze, 0); + rb_define_method(rb_cString, "freeze", rb_str_freeze, 0); rb_define_method(rb_cString, "to_i", rb_str_to_i, -1); rb_define_method(rb_cString, "to_f", rb_str_to_f, 0); -- cgit v1.2.3