I’ve created a mix project with a single file which looks like this
defmodule Bins do
def my_binary_to_list(<<h, t::bytes>>), do: [h | my_binary_to_list(t)]
def my_binary_to_list(<<>>), do: []
def after_zero(<<0, t::bytes>>), do: t
def after_zero(<<_, t::bytes>>), do: after_zero(t)
def after_zero(<<>>), do: <<>>
def all_but_zeros_to_list(buffer, acc, 0), do: {:lists.reverse(acc), buffer}
def all_but_zeros_to_list(<<0, t::bytes>>, acc, remaining), do: all_but_zeros_to_list(t, acc, remaining - 1)
def all_but_zeros_to_list(<<byte, t::bytes>>, acc, remaining), do: all_but_zeros_to_list(t, [byte | acc], remaining - 1)
def not_opt_eq([h | t1], <<h, t2::bytes>>), do: not_opt_eq(t1, t2)
def not_opt_eq([_ | _], <<_, _::bytes>>), do: false
def not_opt_eq([], <<>>), do: true
def opt_eq(<<h, t1::bytes>>, [h | t2]), do: opt_eq(t1, t2)
def opt_eq(<<_, _::bytes>>, [_ | _]), do: false
def opt_eq(<<>>, []), do: true
def match_body([0 | _], <<_h, _::bytes>>), do: :done
def match_head(list, <<_::10, data::bytes>>), do: match_body(list, data)
def count1(<<_, t::bytes>>, count), do: count1(t, count + 1)
def count1(<<>>, count), do: count
def count2(<<h, t::binary>>, count), do: count2(t, count + 1)
def count2(<<>>, count), do: count
def count3(<<_h, t::binary>>, count), do: count3(t, count + 1)
def count3(<<>>, count), do: count
end
but when I run
ERL_COMPILER_OPTIONS=bin_opt_info mix compile
no warnings about about binary optimizations are printed. What am I doing wrong?
The code is from http://erlang.org/doc/efficiency_guide/binaryhandling.html