[erlang-questions] BEAM micro-optimization: term comparison (> 0) versus pattern-matching
Ulf Wiger
ulf@REDACTED
Wed Jun 7 16:02:41 CEST 2017
2017-04-16 14:41 GMT+01:00 Mikael Pettersson <mikpelinux@REDACTED>:
> Mikael Pettersson writes:
> ...
> f is option 1 above, g is option 2. h is g with added is_integer/1 check.
> i is f but with integer tags not atoms. j wraps the two cases as [X|[]]
> and {Y}.
> k is j but with Y left unwrapped. l is j but swaps the order and checks
> with
> is_integer/1 before matching on [Y|_].
>
Just a note: [X|[]] and [X] result in identical abstract code.
BR,
Ulf W
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://erlang.org/pipermail/erlang-questions/attachments/20170607/39223126/attachment.htm>
More information about the erlang-questions
mailing list