[Patch] Simple tweak to string::_Rep::_S_create

Paolo Carlini pcarlini@suse.de
Tue Oct 12 16:42:00 GMT 2004


Hi,

many improvements are possible, and this is only a start that basically
just simplifies and cleanups things: the exponential policy is used
consistently when reallocating the string. Nothing changes for new
strings, this is for another time...

While experimenting with various possibilities I have also noticed a
couple of trivial bugs in array_allocator and its test #2.

For this simple benchmark, on the usual P4-2400 machine:

#include <string>

int main()
{
  for (unsigned i = 0; i < 200000; ++i)
    {
      std::string a;
      for (unsigned j = 0; j < 400; ++j)
    a.append(1, 'x');
    }
}

mainline
--------
10.200u 0.000s 0:10.23  99.7%    0+0k 0+0io 167pf+0w

mainline + patch
----------------
 3.270u 0.010s 0:03.28 100.0%    0+0k 0+0io 167pf+0w


Regtested on x86/x86_64/ia64-linux.

Paolo.

////////////////////
-------------- next part --------------
An embedded and charset-unspecified text was scrubbed...
Name: CL_string_create_final
URL: <http://gcc.gnu.org/pipermail/libstdc++/attachments/20041012/edfaaf16/attachment.ksh>
-------------- next part --------------
An embedded and charset-unspecified text was scrubbed...
Name: patch_string_create_final
URL: <http://gcc.gnu.org/pipermail/libstdc++/attachments/20041012/edfaaf16/attachment-0001.ksh>


More information about the Libstdc++ mailing list