[erlang-questions] efficient binary escape
Dmitry Kolesnikov
dmkolesnikov@REDACTED
Tue Apr 17 22:43:24 CEST 2012
Hello Erlangers!
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
* binary:replace
* sub(<<$,, Rest/binary>>, Acc) ->
sub(Rest, <<Acc/binary, $\, $,>>)
....
two slow for me!
Do you have any suggestion? What is you experience?
Thanks is advanced!
- Dmitry
More information about the erlang-questions
mailing list