Re: suggestion: slight optimization for UT_String


Subject: Re: suggestion: slight optimization for UT_String
From: Vlad Harchev (hvv@hippo.ru)
Date: Mon Mar 19 2001 - 04:04:57 CST


On Mon, 19 Mar 2001, Joaquín Cuenca Abela wrote:

> Mike Nordell wrote:
> >
> > 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.
>
> ops, good catch
>
> > 2. Floating point operations should in this case (IMHO) be avoided (simple
> > to fix, but since you provided an alternative implementation :-) ).

Then the following could be used to multiply 'x' by 1.5:
        (x + x<<1) >> 1

I will be very fast.

 Best regards,
  -Vlad



This archive was generated by hypermail 2b25 : Mon Mar 19 2001 - 04:52:50 CST