[phobos] std.base64 replacement

Masahiro Nakagawa repeatedly at gmail.com
Fri Oct 29 09:38:14 PDT 2010


11. Please give me a diff file.

I cannot use a Mac, so I will reply other things later.

Masahiro

2010/10/29 20:03 "Daniel Murphy" <yebblies at gmail.com>:

On Fri, Oct 29, 2010 at 6:27 PM, Masahiro Nakagawa <repeatedly at gmail.com>
wrote:
>
> You are right. ...
Great!
I think it should be "'\\0'..." rather than "'\0'...", otherwise it
will just embed a null character into the error.

There should also be another space:
static assert(Padding < '0' || Padding > '9', "Character '" ~ Padding
~ "'cannot be used twice");
static assert(Padding < '0' || Padding > '9', "Character '" ~ Padding
~ "' cannot be used twice");



>
> Your suggestion increases struct size and decreases performance.
> But, I agree.
>
> http://bi...
It's not very pretty, but without it encoder and decoder don't
correctly implement the range interface.

Some more things:
1. isArray should be isDynamicArray
2. Need to import std.array for put(a, b)

3. The 4 implementations of encode could be merged into 2 using static
ifs.  This will result in some very ugly code, but will cut down on
code duplication and greatly simplify the method signature.  Same
thing for decode.

4. The decoder chunk range takes both ubyte[] and char[], while the
decode function only takes ubyte[].  They should both probably take
the same types.

5. Chunk version of decoder does not call doDecoding in the constructor.

6. Chunk versions of encoder/decoder do not define save correctly
(should make a copy of the buffered data to prevent aliasing)

7. The requirement that decoder should take chunks with a size that is
a multiple of 4 must either be asserted or removed.  The encoder range
needs a warning that padding will be added to the end of each chunk.
The warnings need to be much bigger and appear earlier in the
documentation for each range.

7.5.  Considering that it says chunks must be a multiple of 4, it is
not necessary for doDecoding to read more than one chunk from the
input.  This should eliminate all the extra allocations in Decoder.

8. The encoder and decoder shortcut functions probably need to have a
copy of the template constraints.  This will give better error
messages.

9. The line Appender!(char[])([]); gives me an error about converting
arrays of void[].  Changing it to Appender!(char[])(null); gets rid of
it.  Is this still present with the newest dmd?

10. The block of unittests at 1450 still refuses to compile for me.
Again, this might be because I'm using 2.048.  The errors are about
using to!ubyte, and passing map to encode.

11.  Some of the documentation comments are not very good english
(sorry).  I assume you are not a native english speaker, I can update
them if you would like.

Thanks!

_______________________________________________
phobos mailing list
phobos at puremagic.com
http://list...
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.puremagic.com/pipermail/phobos/attachments/20101030/dad372f1/attachment.html>


More information about the phobos mailing list