------- Comment #8 from pcarlini at suse dot de  2006-09-12 20:45 -------
(In reply to comment #7)
> ...
> > "problematic" are string assigns, not += and you are moving the reserve
> > *after* the assign. 
> 
> Yes, but in the every assign the capacity would still be lost. This would mean
> the reserve would happen once after each assign, and not in every iteration of
> the loop. This is obviously better then my first naive attempt, where it
> happend in (almost) every loop, but it would still be a bit slower than doing
> the resize()/reseve() once completely outside the two loops and the carefully
> avoid the resizing completely inside the loops.

I see this specific point and I agree, I expect "a bit slower", not more.

> (... and since you're the right person I just ask) I guess assign(const char*
> buf, unsigned int length); should be even faster ?

Certainly.

> Starting to think about weird hacks:
> how about keeping the shared-data during string assignment as it is now but
> additionally keep a pointer to the eventually already allocated buffer around,
> so that it can be reused as soon as copy-on-write is required ?

I see this point too, I have been thinking about something along those lines,
but you understand that we have an ABI, which we *must* keep absolutely stable,
also from the point of view of interoperability between object modules. Trust
me, at this point we can't change the default string class so profoundly and,
in any case, as I mentioned already, we have a new, non-reference counted
implementation ready, we are concentrating our efforts on it.

> > Likewise, just look at the sources (we are on free software projects, 
> > right? ;)
> 
> /me feels like looking already at the sources of enough (both free and closed
> source) projects.

Ok ;) In this case it was easy to see that resize fills the buffer with
CharT().

All in all, I'm inclined to believe that your PR has a point of course but we
cannot really fix the issue, we cannot improve the current string class the way
you would like. Any objections to closing it as WONTFIX?


-- 


http://gcc.gnu.org/bugzilla/show_bug.cgi?id=29037

Reply via email to