[erlang-questions] Optimization for the ++ operator

José Valim jose.valim@REDACTED
Thu May 31 13:55:48 CEST 2012


I thought Erlang would optimize the ++ operator when the left side is known
at compile time.

For example, if the compiler sees the following outside of a function
signature:

    "Foo" ++ Bar

It could rewrite it as:

    [$F, $o, $o | assert_list(Bar)]

However, I ran some benchmarks and it seems the optimization does not
happen (on R15B).
With a local dummy implementation of assert_list(Bar), I got that the first
format is 50% slower than the second one.

That said, given the possibility something is odd in my setup, does Erlang
optimize it or not? If not, could it?


*
José Valim
www.plataformatec.com.br
Founder and Lead Developer
*
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://erlang.org/pipermail/erlang-questions/attachments/20120531/10426f8f/attachment.htm>


More information about the erlang-questions mailing list