base64 encoding using the new binary syntax

Matthias.Lang@REDACTED Matthias.Lang@REDACTED
Tue Sep 26 17:17:19 CEST 2000

Bjorn Gustavsson writes:

 > The bit syntax as currently implemented always copies binaries
 > in construction expressions such as:
 > 	<<Acc/binary, P:6, Q:6, R:6, S:6>>

Interesting. Maybe it'd be useful to add a few lines to the online
manual (
about performance---I'd been assuming that all the assertions made in
Tony and Klacke's original paper were true, e.g. they guarantee O(1)
concatenation. Now that I think about it, I remember someone saying
that "segmented binaries" hadn't been implemented, so I should have known.

So, I think it's now something like:

Operation                       big-O     Notes
<<A:N/binary, B:M/binary>>.     O(M + N)  i.e. it copies
<<A:N/binary, B:M/binary>> = X. O(M + N)  if this also copies, otherwise O(1)
<<_:N/binary, B:M/binary>> = X. O(M)      just guessing, O(1) if the above is
<<A:N/binary, _:M/binary>> = X. O(N)      just guessing, ditto

The other thing which might be worth mentioning in the "what was
dropped" section is case-insensitve string matching. 

Updated performance:

              Matthias bitsyntax      Björn bitsyntax	'mimencode' program
    encoding: 1.07 s                  0.33s		0.045s
    decoding: 10.2 s                  0.75s		0.035s
That seems reasonable.


More information about the erlang-questions mailing list