This is the mail archive of the gcc-bugs@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

[Bug libstdc++/20706] string::reserve severe performance regression


------- 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


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]