Skip to content

Instantly share code, notes, and snippets.

@josevalim
Created May 20, 2015 16:33
Show Gist options
  • Save josevalim/d19deed5510ab7d35ec3 to your computer and use it in GitHub Desktop.
Save josevalim/d19deed5510ab7d35ec3 to your computer and use it in GitHub Desktop.

Revisions

  1. José Valim created this gist May 20, 2015.
    16 changes: 16 additions & 0 deletions foo.erl
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,16 @@
    %% When compiled with: erlc +bin_opt_info foo.erl
    %%
    %% It prints:
    %%
    %% foo.erl:13: Warning: NOT OPTIMIZED: compiler limitation: instruction {get_map_elements,
    %% {f,3},
    %% {x,1},
    %% {list,[{atom,state},{x,6}]}} prevents delayed sub binary optimization

    -module(foo).
    -compile(export_all).

    bar(<<Type/integer, Size:32/integer, Data/binary>> = Tail, #{state := State}) ->
    {Type, Size, Data, Tail, State};
    bar(Data, #{tail := Tail}) ->
    {Data, Tail}.