[Mono-devel-list] Re: CodeDom in Compiler.cs

Sébastien Pouliot spouliot at videotron.ca
Tue Apr 5 13:32:13 EDT 2005

Hello Andrew,

> The waste here is to perform additional pass to convert string containing
> base64 characters into byte []. The whole convert can be done in a
> single pass, in principle.

Yes, the current code isn't not optimal. However calling
Convert.FromBase64String won't help as it will by converting the string to a
byte array anyway (before calling the transform) and more...

The solution would be to re-write (like the comment says) the base64
convertion to be more resource-friendly. Without a new, slimer
Convert.FromBase64, the current code is better off using the
FromBase64Transform directly.

> It looks that Normalizer was unnecessary anyway. All it does is changes
> between different kinds of whitespace, and whitespace is anyway ignored
> in Convert.FromBase64String.

Maybe but I recall that at some point the Convert.FromBase64String was buggy
for invalid characters - but this has been fixed (from a correctness point
of view).

> The whole problem is that functionality needed here is exactly covered
> by Convert.FromBase64String function. But because this function was not
> implemented well, David changed the code to use S.S.C. I think, we
> should fix FromBase64String, so every place that uses this function will
> benefit. grep finds 62 places like that, and 19 places with
> FromBase64CharArray.

For what it's worth, I agreed on the solution ;-). This is one of many place
which "works" but could be enhanced. But until it is done I don't think we
should remove the use of the FromBase64Transform (but that's up to Atsushi).

Anyone doing this, now or in the future, should also check the new options
introduced in 2.0 for ToBase64[String|CharArray] methods. Also, on a
positive note, I think there enough unit tests/internal usage of the base64
code to minimize the risk of regressions if somewhat wants to optimize this.

>  > As anyway Convert.FromBase64String won't work if S.S.C isn't available?
> We have this function implemented in Java.

Ok I see the dilemma now. Maybe you can #if TARGET_* this part to use your
Java version (with a few good comments) until then ?

Sebastien Pouliot
home: spouliot at videotron.ca
blog: http://pages.infinit.net/ctech/poupou.html

More information about the Mono-devel-list mailing list