On Wed, 2008-11-05 at 15:57 -0500, Dale Worley wrote:
> On Tue, 2008-11-04 at 16:32 -0500, Dale Worley wrote:
> > On Tue, 2008-11-04 at 16:22 -0500, Dans, Raymond (CAR:9D30) wrote:
> > > I don't think its as much a problem in myvsprintf as it was in the
> > > "escape" method.  I just looked through this method and noticed that it
> > > could be a little smarter.
> > 
> > Ugh, yes!  escape() uses UtlString::append().  Ultimately, all the
> > UtlString::append() methods use UtlString::capacity() to resize the
> > string, which if you are appending single characters, adds only 100
> > characters at a time.
> 
> While we're at it, we should fix UtlString::capacity to add a particular
> percentage of the length of the string, rather than a fixed number of
> bytes.  As it is currently, any code that adds a large number of items
> to a string will tend to have N^2 running time.

If the caller can provide a percentage, the caller can provide an
absolute value.  If the caller is going to be adding so much that N^2
becomes a problem, it should anticipate the problem and pre-allocate the
string in one shot (which does not have the problem Raymond started
with).

_______________________________________________
sipx-dev mailing list
[email protected]
List Archive: http://list.sipfoundry.org/archive/sipx-dev
Unsubscribe: http://list.sipfoundry.org/mailman/listinfo/sipx-dev

Reply via email to