ruby-changes:33457
From: nobu <ko1@a...>
Date: Wed, 9 Apr 2014 12:50:11 +0900 (JST)
Subject: [ruby-changes:33457] nobu:r45536 (trunk): string.c: remove unnecessary terminator space
nobu 2014-04-09 12:50:07 +0900 (Wed, 09 Apr 2014) New Revision: 45536 http://svn.ruby-lang.org/cgi-bin/viewvc.cgi?view=rev&revision=45536 Log: string.c: remove unnecessary terminator space * string.c (str_buf_cat): remove unnecessary terminator space, since the capacity does not include its length but RESIZE_CAPA() considers it. Modified files: trunk/string.c Index: string.c =================================================================== --- string.c (revision 45535) +++ string.c (revision 45536) @@ -2009,7 +2009,6 @@ static VALUE https://github.com/ruby/ruby/blob/trunk/string.c#L2009 str_buf_cat(VALUE str, const char *ptr, long len) { long capa, total, off = -1; - const int termlen = TERM_LEN(str); if (ptr >= RSTRING_PTR(str) && ptr <= RSTRING_END(str)) { off = ptr - RSTRING_PTR(str); @@ -2028,11 +2027,11 @@ str_buf_cat(VALUE str, const char *ptr, https://github.com/ruby/ruby/blob/trunk/string.c#L2027 total = RSTRING_LEN(str)+len; if (capa <= total) { while (total > capa) { - if (capa + termlen >= LONG_MAX / 2) { + if (capa > LONG_MAX / 2) { capa = (total + 4095) / 4096 * 4096; break; } - capa = (capa + termlen) * 2; + capa = 2 * capa; } RESIZE_CAPA(str, capa); } -- ML: ruby-changes@q... Info: http://www.atdot.net/~ko1/quickml/