[erlang-questions] Binary pattern matching and optimization

Bob Ippolito <>
Mon Nov 24 21:23:32 CET 2008


That used to be true, but it's supposed to be faster in R12+ to do it
in the "obvious" way.

On Mon, Nov 24, 2008 at 11:27 AM, Vance Shipley <> wrote:
> Robert,
>
> My thinking was that reading a big binary and then passing it
> with offsets to various parsing functions would be easier on
> the emulator than creating a new binary for each one.  Is it
> the case that the compiler will optimize away the creation of
> these binaries?
>
>        -Vance
>
> On Mon, Nov 24, 2008 at 08:10:38PM +0100, Robert Virding wrote:
> }  The compiler and VM is smart and optimises the matching of a binary where
> }  the last segment is a binary. This makes it more efficient to use a binary
> }  like a list and pick things off the front.
> }
> }  *BUT* for this to work the reference to the whole binary, Bin your case,
> }  must not be used after the match, then the compiler can reuse that binary
> }  reference and save work. You reuse Bin and the compiler is warning you that
> }  when you do this it can't do a good a job as possible.
> _______________________________________________
> erlang-questions mailing list
> 
> http://www.erlang.org/mailman/listinfo/erlang-questions
>



More information about the erlang-questions mailing list