Conditional iolist_to_binary?

Loïc Hoguin essen@REDACTED
Fri Dec 27 11:07:16 CET 2019


Hello,

I seem to be getting a small but noticeable performance improvement when 
I change the following:

Value = iolist_to_binary(Value0)

Into the following:

Value = if
     is_binary(Value0) -> Value0;
     true -> iolist_to_binary(Value0)
end

At least when the input data is mostly binaries. Anyone else seeing this?

The only difference between is_binary and iolist_to_binary seems to be 
that is_binary calls is_binary/binary_bitsize on the same if expression 
while iolist_to_binary has two if statements.

What gives?

Cheers,

-- 
Loïc Hoguin
https://ninenines.eu



More information about the erlang-questions mailing list