performance - Which is more efficient in Erlang: match on two different lines, or match in tuple? -


which of these 2 more efficient in erlang? this:

valuea = myrecord#my_record.value_a, valueb = myrecord#my_record.value_b. 

or this:

{valuea, valueb} = {myrecord#my_record.value_a, myrecord#my_record.value_b}. 

?

i ask because latter brings me need multiple lines fit in 80 character line length limit keep, , tend prefer avoid doing stuff this:

{valuea, valueb} = { myrecord#my_record.value_a                    , myrecord#my_record.value_b }. 

they generate same code! if want less code try using:

#my_record{value_a=valuea,value_b=valueb} = myrecord 

which generates same code. generally, if can, use pattern matching. never worse, better. in case minimum amount of work necessary.

in general write code clearest , looks best , worry these types of optimisation when know there speed problem code.


Comments

Popular posts from this blog

java - Jmockit String final length method mocking Issue -

asp.net - Razor Page Hosted on IIS 6 Fails Every Morning -

c++ - wxwidget compiling on windows command prompt -