[Mono-devel-list] Re: [Mono-patches] r46353 - trunk/mcs/class/System.XML/System.Xml

Atsushi Eno 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.

Atsushi Eno

> 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);
> else
> 	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
> http://lists.ximian.com/mailman/listinfo/mono-devel-list

More information about the Mono-devel-list mailing list