This is the mail archive of the
gcc-bugs@gcc.gnu.org
mailing list for the GCC project.
[Bug libstdc++/20706] string::reserve severe performance regression
- From: "pcarlini at suse dot de" <gcc-bugzilla at gcc dot gnu dot org>
- To: gcc-bugs at gcc dot gnu dot org
- Date: 31 Mar 2005 20:57:00 -0000
- Subject: [Bug libstdc++/20706] string::reserve severe performance regression
- References: <20050331202728.20706.ftr@highstreetnetworks.com>
- Reply-to: gcc-bugzilla at gcc dot gnu dot org
------- Additional Comments From pcarlini at suse dot de 2005-03-31 20:56 -------
This is not a bug, it's the intended, standard conforming, behavior.
This is happening because, when you call dest.reserve(dest.length() + 1) the
string class is actually *shrinking* the capacity of the string, which at that
point, is *larger* than dest.length + 1. This implies slow reallocations.
In 3.4 (at variance with 3.3) we honor shrink requests, which happen when
reserve is passed an argument which is smaller than the current capacity. This
is very useful to spare memory, in some applications.
In order to fix the problem, make sure to always pass to reserve an argument
bigger than the current capacity.
*** This bug has been marked as a duplicate of 20114 ***
--
What |Removed |Added
----------------------------------------------------------------------------
Status|UNCONFIRMED |RESOLVED
Resolution| |DUPLICATE
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=20706