binary constructor

Mats Cronqvist <>
Mon Feb 28 11:36:25 CET 2005



Richard Carlsson wrote:
>[...]
 >   For example, there is no point in doing:
> 
>     A = list_to_binary(As),
>     B = list_to_binary(Bs),
>     Bin = <<A/binary, B/binary>>
> 
> (creating 2 temporary binaries) since you can simply do
> 
>     Bin = list_to_binary([As,Bs])
> 
> if you're just concatenating bytes. 

   well, according to timer:tc/3;

<<list_to_binary(As)/binary,list_to_binary(Bs)/binary>>

   is (marginally) faster than;

list_to_binary([As,Bs])

   mats



More information about the erlang-questions mailing list