[Mono-devel-list] Re: [Mono-patches] r46353 - trunk/mcs/class/System.XML/System.Xml
atsushi at ximian.com
Wed Jun 22 14:45:49 EDT 2005
Ok, it is an interesting tip. Now checked in svn as r46380. Thanks.
> I think this needs to be changed to make it optimal for the normal case.
> Gonzalo's situation is a corner case: 1 huge field in the middle of tons
> of stuff. However, normally, there are many, small, similarly sized
> fields. So what happens is that the string builder does the standard
> "double when there is too much data". Most strings will end up being (on
> average) 25% larger than they need to be.
> Therefore, we should do something like this:
> if (sb.Capacity < 100)
> return sb.Substring (0, sb.Length);
> return sb.ToString ();
> That way, if the string is small, "substring" will be used. It will
> create a string of the exact size we want. The stringbuilder buffer can
> then be reused.
> -- Ben
> Mono-devel-list mailing list
> Mono-devel-list at lists.ximian.com
More information about the Mono-devel-list