On Sun, May 14, 2006 at 01:40:24PM -0700, Daniel Burrows wrote: > With respect to that change, I wonder whether the speedup is from > changing += to push_back, or from changing += to copy() (perhaps > checking for the null terminator is expensive?). In the latter case, > how does string.append perform compared to +=? Using append() instead of += doesn't seem to make a difference performancewise. I did some profiling with a current version of libstdc++. I think things have changed since I filed this bug. A big portion of the slowness (20% of the total execution time of QuoteString()) with strings comes now from string::reserve(). Now with a current libstdc++ the string version can be made actually faster than the vector version simply by doing Res.reserve(Str.length()*3/2) in the beginning. Which is good :) (That wasn't the case back then, I remember testing it.) After adding the Res.reserve() call, strchr() consumes 62% of all time spent in QuoteString(). Which is exactly why I wrote the QuoteURI() function that runs in roughly 36% of the time taken by a corresponding QuoteString() call. Of course another good question is why QuoteString() is called that often while browsing packages in aptitude. I think that function was the main cause of slowness in moving from one package to the next one in a slow computer. Sami
Attachment:
signature.asc
Description: Digital signature