[erlang-questions] efficient binary escape
Tue Apr 17 22:43:24 CEST 2012
I'd like to get your opinion on the binary escaping techniques using erlang-only.
Let's say that I have binary <<"ab,cdef,qwert,yuiop,....">> I wish to escape (substitute) comma by \, to get <<"ab\\,cdef\\,qwert\\,yuiop,....">>. In other words, a single byte of binary sequence has to be replaced by multiple bytes.
and I do have about 35 - 50M tokens to procedure. The straight forward approaches like
* sub(<<$,, Rest/binary>>, Acc) ->
sub(Rest, <<Acc/binary, $\, $,>>)
two slow for me!
Do you have any suggestion? What is you experience?
Thanks is advanced!
More information about the erlang-questions