Re: proposed change to UT_String

Subject: Re: proposed change to UT_String
From: Joaquín Cuenca Abela (
Date: Sat Apr 14 2001 - 17:34:01 CDT

Mike Nordell wrote:
> Joaquín wrote:
> > What do you (Mike?) think about changing the clear method of
> > UT_Stringbuf from
> >
> > if (m_psz)
> > {
> > delete[] m_psz;
> > m_psz = 0;
> > m_pEnd = 0;
> > m_size = 0;
> > }
> >
> > to only
> >
> > if (m_psz)
> > m_size = 0;
> No good at all. m_size is the capacity() of this container. Zeroing that one
> would make it reallocate the buffer upon every assign() after clear(), even
> if the buffer was large enough to hold the data.
> What might do the trick would be:
> m_pEnd = m_psz;

of course. Need sleep, sorry.

> Are there any performance figures (or at least a reasurring "I've tested it,
> it hurts performance") telling us this is the right thing to do?

nope, I was just thinking about the most current implementation of stl
vector, and asking for something like that for UT_String. I don't
really think that it would impact very much our speed.

> For completeness, so you or anyone else can verify my words, I also attached
> my test files for the string class. If anyone knows where we should put this
> kind of tests in the tree, please commit.

if these are the same tests that I saw last time, we will not see any
gain at all with this change. To see the gain we should have a string,
fill it with something, clear it, refill it with something else, reclear
it, and so on.

I think that in this scenario it will actually make a difference.


Joaquín Cuenca Abela

This archive was generated by hypermail 2b25 : Sat Apr 14 2001 - 17:34:09 CDT