Performance Gcc 3.3.1 VS 2.95.1

Mike Capp mike.capp@gmail.com
Wed Oct 27 13:41:00 GMT 2004


> Ouch!  By manipulating the capacity in that way, you force quadratic
> performance!  The string has to be reallocated every time.  Take out
> your explicit management of capacity and things will get much faster.

> If 2.95.1 ran this code faster, I assume it must have ignored your
>calls to reserve().

Not necessarily. basic_string::reserve guarantees *at least* the
requested capacity; it may well allocate more.  If, f'rinstance,
2.95.1 rounded reservations up to the next multiple of 64 chars, and
3.3.1 rounded up to the next multiple of 16, then 3.3.1 would need to
reallocate more frequently, explaining the OP's performance
observations.

Don't know if this was actually the case; I'm just speculating.

cheers,
Mike



More information about the Gcc mailing list