diff -urN libstdc++-v3-orig/include/bits/basic_string.tcc libstdc++-v3/include/bits/basic_string.tcc --- libstdc++-v3-orig/include/bits/basic_string.tcc 2004-09-28 10:58:31.000000000 +0200 +++ libstdc++-v3/include/bits/basic_string.tcc 2004-10-13 02:42:11.000000000 +0200 @@ -503,9 +503,8 @@ // low-balling it (especially when this algorithm is used with // malloc implementations that allocate memory blocks rounded up // to a size which is a power of 2). - const size_type __pagesize = 4096; // must be 2^i * __subpagesize - const size_type __subpagesize = 128; // should be >> __malloc_header_size - const size_type __malloc_header_size = 4 * sizeof (void*); + const size_type __pagesize = 4096; + const size_type __malloc_header_size = 4 * sizeof(void*); // The below implements an exponential growth policy, necessary to // meet amortized linear time requirements of the library: see @@ -513,14 +512,7 @@ // It's active for allocations requiring an amount of memory above // system pagesize. This is consistent with the requirements of the // standard: http://gcc.gnu.org/ml/libstdc++/2001-07/msg00130.html - - // The biggest string which fits in a memory page - const size_type __page_capacity = ((__pagesize - __malloc_header_size - - sizeof(_Rep) - sizeof(_CharT)) - / sizeof(_CharT)); - - if (__capacity > __old_capacity && __capacity < 2 * __old_capacity - && __capacity > __page_capacity) + if (__capacity > __old_capacity && __capacity < 2 * __old_capacity) __capacity = 2 * __old_capacity; // NB: Need an array of char_type[__capacity], plus a terminating @@ -538,12 +530,6 @@ __capacity = _S_max_size; __size = (__capacity + 1) * sizeof(_CharT) + sizeof(_Rep); } - else if (__size > __subpagesize) - { - const size_type __extra = __subpagesize - __adj_size % __subpagesize; - __capacity += __extra / sizeof(_CharT); - __size = (__capacity + 1) * sizeof(_CharT) + sizeof(_Rep); - } // NB: Might throw, but no worries about a leak, mate: _Rep() // does not throw. diff -urN libstdc++-v3-orig/include/ext/array_allocator.h libstdc++-v3/include/ext/array_allocator.h --- libstdc++-v3-orig/include/ext/array_allocator.h 2004-10-08 00:06:22.000000000 +0200 +++ libstdc++-v3/include/ext/array_allocator.h 2004-10-13 02:12:31.000000000 +0200 @@ -116,11 +116,11 @@ pointer allocate(size_type __n, const void* = 0) { - static size_type used; - if (__builtin_expect(used > array_type::_S_index, false)) + static size_type __used; + if (__builtin_expect(__used + __n > array_type::_S_index, false)) throw std::bad_alloc(); - pointer __ret = _M_array->begin() + used; - used += __n; + pointer __ret = _M_array->begin() + __used; + __used += __n; return __ret; } }; diff -urN libstdc++-v3-orig/testsuite/ext/array_allocator/2.cc libstdc++-v3/testsuite/ext/array_allocator/2.cc --- libstdc++-v3-orig/testsuite/ext/array_allocator/2.cc 2004-10-08 00:06:23.000000000 +0200 +++ libstdc++-v3/testsuite/ext/array_allocator/2.cc 2004-10-13 02:12:31.000000000 +0200 @@ -32,7 +32,7 @@ typedef char char_type; typedef std::char_traits traits_type; -typedef std::tr1::array array_type; +typedef std::tr1::array array_type; array_type extern_array; diff -urN libstdc++-v3-orig/testsuite/performance/21_strings/string_append_2.cc libstdc++-v3/testsuite/performance/21_strings/string_append_2.cc --- libstdc++-v3-orig/testsuite/performance/21_strings/string_append_2.cc 1970-01-01 01:00:00.000000000 +0100 +++ libstdc++-v3/testsuite/performance/21_strings/string_append_2.cc 2004-10-13 02:44:10.000000000 +0200 @@ -0,0 +1,55 @@ +// Copyright (C) 2004 Free Software Foundation, Inc. +// +// This file is part of the GNU ISO C++ Library. This library is free +// software; you can redistribute it and/or modify it under the +// terms of the GNU General Public License as published by the +// Free Software Foundation; either version 2, or (at your option) +// any later version. + +// This library is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. + +// You should have received a copy of the GNU General Public License along +// with this library; see the file COPYING. If not, write to the Free +// Software Foundation, 59 Temple Place - Suite 330, Boston, MA 02111-1307, +// USA. + +// As a special exception, you may use this file as part of a free software +// library without restriction. Specifically, if other files instantiate +// templates or use macros or inline functions from this file, or you compile +// this file and link it with other files to produce an executable, this +// file does not by itself cause the resulting executable to be covered by +// the GNU General Public License. This exception does not however +// invalidate any other reasons why the executable file might be covered by +// the GNU General Public License. + +#include +#include + +// Short strings didn't grow quickly... +void test01() +{ + using namespace __gnu_test; + time_counter time; + resource_counter resource; + + start_counters(time, resource); + for (unsigned i = 0; i < 200000; ++i) + { + std::string a; + for (unsigned j = 0; j < 400; ++j) + a.append(1, 'x'); + } + stop_counters(time, resource); + + report_performance(__FILE__, "", time, resource); + clear_counters(time, resource); +} + +int main() +{ + test01(); + return 0; +}