Re: suggestion: slight optimization for UT_String


Subject: Re: suggestion: slight optimization for UT_String
From: Mike Nordell (tamlin@algonet.se)
Date: Sun Mar 18 2001 - 22:52:18 CST


Joaquín Cuenca Abela wrote:
> What are your feelings about changing current growing algorithm of
> UT_StringBuf from a:
>
> n + 4
>
> to
>
> max(old * 1.5, n)
> (ie, switch to a exponential growing algorithm).

Has tests shown that we do that much appending? If so, I'm all for it
(conceptually), but not implementation-wise.
1. The "n" in g_nGrowFactor says "I'm an integral type" why you can't stuff
1.5 into it.
2. Floating point operations should in this case (IMHO) be avoided (simple
to fix, but since you provided an alternative implementation :-) ).
3. You might consider not using "max" for at least two reasons. C++ "max"
uses templates which are forbidden in AW, and M$ implementation doesn't even
give you access to it using its standard name. Either MyMax from ut_types.h
(though that would include loads of unneccessary stuff that at least I'd
dislike) or simply create your own local MyMax macro in ut_stringbuf.cpp.

While at it, could you remove the "replace" member function declaration
(it's never defined) and remove the redundant "if (m_psz)" around "delete[]
m_psz" in the grow_xxx functions?

Thanks,

/Mike



This archive was generated by hypermail 2b25 : Sun Mar 18 2001 - 22:53:56 CST