[Mono-devel-list] patch for TextWriter

Ben Maurer bmaurer at ximian.com
Sun Dec 5 18:55:51 EST 2004

On Mon, 2004-12-06 at 07:54 +0900, Atsushi Eno wrote:
> Hi,
> I attached a patch for TextWriter.cs not to create a new string for
> every call to NewLine. If no problem, I'll check in later. One concern
> I have is that it costs one string field (which might be extraneous
> for some kind of use.)

`CoreNewLine' could be modified by someone, since it is protected. So,
it is invalid to cache it.

An easier way to do it is to just say:

	Write (CoreNewLine);

in the WriteLine method. This will be just as efficient, as it does not
make a string. Also, it avoids the virtual call to get the newline. I
have checked this change in.

MSFT was a bit braindead here. It would have been a much better idea to
use a string for this, as it is immutable. But they can't change that
now, sadly.

-- Ben

More information about the Mono-devel-list mailing list