Re: proposed change to UT_String


Subject: Re: proposed change to UT_String
From: Mike Nordell (tamlin@algonet.se)
Date: Sat Apr 14 2001 - 16:43:38 CDT


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;

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?

> Of course, we should change too the destructor (something like
>
> clear();
> delete[] m_psz;
>
> will do the work).

I'd remove the clear() call.

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.

/Mike





This archive was generated by hypermail 2b25 : Sat Apr 14 2001 - 16:43:14 CDT