summaryrefslogtreecommitdiff
path: root/string.c
diff options
context:
space:
mode:
authornobu <nobu@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2014-04-09 03:50:07 +0000
committernobu <nobu@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2014-04-09 03:50:07 +0000
commit5c7564c9e2df731e2bc6d82bf9b41c32f7b480d0 (patch)
treeeb0f3bb57ae866bb501867f8a3b0754dced565cf /string.c
parentf2ba957058b7ac4ff750bf6bb08907fd8f89dbef (diff)
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. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@45536 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
Diffstat (limited to 'string.c')
-rw-r--r--string.c5
1 files changed, 2 insertions, 3 deletions
diff --git a/string.c b/string.c
index ccf265738e..56b27d9d75 100644
--- a/string.c
+++ b/string.c
@@ -2009,7 +2009,6 @@ static VALUE
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, long len)
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);
}