Binary Matching

Raimo Niskanen raimo@REDACTED
Wed Aug 22 08:45:10 CEST 2001


Kent Johnson wrote:
> 
> Does the following code result in a memory copy.
> 
> parse(<<Char:8, Rest/binary>>) ->
>         %% Do any parsing required
>         parse(Rest);
> parse(<<>>) ->
>         ok.
> 

No, not really. For every recursion one new sub-binary will be created
and one will become garbage. The sub-binary is a header of a few words
that shares contents with the original binary to parse.

/ Raimo Niskanen, Erlang/OTP, Ericsson UAB.



More information about the erlang-questions mailing list