[Mono-list] System.Text.ASCIIEncoding patch

Dietmar Maurer dietmar@ximian.com
Sun, 17 Mar 2002 10:55:44 +0100


Mike Kestner wrote:

> On Fri, 2002-03-15 at 03:15, Dietmar Maurer wrote:
> > On Fri, 2002-03-15 at 06:17, Mike Kestner wrote:
>
> > It is a long time ago when I wrote those classes, but I thought
> > ASCIEncoding is already working. Why do you overwrite GetBytes, GetChar,
> > ... - most of them should be handled by the base class (Encoder).
>
> Well, I got started on the exercise because the class-status page showed
> the class having a lot of unimplemented methods.  The mscorlib overrides
> all the methods that I've implemented.

see: http://www.go-mono.org/class-status/System.Text.html, completion 99%

> If it was working already, I don't know how anyone else would have known
> that without a public test suite. Also, the previous implementation of
> GetMaxByteCount didn't exactly inspire the image of a complete,
> well-tested implementation.  I suppose I could have written the tests
> before filling in the class, but it sure looked like a stubbed
> implementation at first glance.

I put an entry to the class status page, saying that it is 99% complete. I
think that's enough, and if you look at the code you can see the
implementation.

> Anyway, as to the overriding of the Get(Byte|Char)s methods, using
> internal calls to an iconv based converter seems a bit heavy when a
> simple comparison to 0x7f in managed code is all that is needed.  Yeah,
> this is an optimization of unprofiled code, but it was a trivial one.
>
> So, now that we've had the philosophical discussion, does anyone have
> any comments on the code I posted.  If not, I'll commit it this weekend
> with a test suite.

Feel free to commit if you are sure this optimization works. The nice thing
about the iconv code is that you do not need any knowledge about encodings
;-)

- Dietmar