In r12b, the most natural way to construct and match binary types is much faster than in the previous version. You can use the following simple code to construct a binary type:
Write this (in r12b)/Beg not to write (in the version prior to r12b)
my_list_to_binary (listmy_list_to_binary(list, <<>>). My_list_to_binary([H| Taccmy_list_to_binary(t, <<Acc/binary,H >>); my_list_to_binary ACC Acc.
In a release prior to R12B, ACC is duplicated in each iteration. In r12b, ACC is replicated only in the first iteration, and after that, it opens up additional memory space. In the next iteration, H is written to additional memory. When the extra memory is full, the binary will re-expand the extra memory. The expanded memory is twice times the size of the binary, or 256, whichever is larger than the binary type.
The most natural way to match the binary type is now the fastest.
So write (in r12b)
my_binary_to_list (<<H,T/binary>>) [h| my_binary_to_list (T)]; my_binary_to_list (<<>>), [].
Construction and matching of effective erlang--binary type