[erlang-questions] flash clauses vs nested clauses
Zheng Zhibin
witeman.g@REDACTED
Fri Apr 6 03:29:05 CEST 2012
I think the first style of coding would be faster.
Thanks and regards,
郑智斌(Witeman)
在 2012-4-5,下午11:22, Pablo Platt 写道:
> Hi,
>
> Is there a difference in performance between using nested clauses and flat clauses
> or is the compiler smart enough to produce the same optimizations?
>
> For example:
>
> somefun(a1, b1, c1) ->
> res1;
> somefun(a1, b1, c2) ->
> res2;
> somefun(a1, b1, c3) ->
> res3;
> somefun(a1, b2, c1) ->
> res4;
> somefun(a1, b2, c2) ->
> res5;
> somefun(a2, b1, c1) ->
> res6;
> somefun(a2, b1, c2) ->
> res7;
> ...
> somefun(a10, b10, c10) ->
> res10.
>
>
> and
>
> somefun(a1, B, C) ->
> case B of
> b1 ->
> case C of
> c1 -> res1;
>
> c2 -> res2;
>
> c3 -> res3
>
> end;
> b2 ->
> case C of
> C1 -> res4;
>
> C2 -> res5
> end
>
> end;
> somefun(a2, B, C) ->
> ...
>
> Thanks
>
> _______________________________________________
> erlang-questions mailing list
> erlang-questions@REDACTED
> http://erlang.org/mailman/listinfo/erlang-questions
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://erlang.org/pipermail/erlang-questions/attachments/20120406/a9fc4ddf/attachment.htm>
More information about the erlang-questions
mailing list