+ 2

Return | Simple function

I was thinking if someone know an advantage/problem to convert a basic function from: function( param1, param2 ){ var result = param1 % param2; return result; } To something like: function( param1, param2 ){ return param1 % param2; } When we do not need to check params or do something else? Cause I'm curious to know if declare X times the same var is good for performances.

16th Mar 2017, 1:48 PM
Geoffrey L
Geoffrey L - avatar
2 Réponses
+ 1
I think declaring less local variable is good for performance because it consumes less registry in the processor, in c# we are suggested to only have 64 locals including compiler generated variable in a method because the processor registry only can hold maximum 64 locals.
16th Mar 2017, 3:57 PM
gjh4cker
gjh4cker - avatar
+ 1
Ok, thanks for your answer, I guessed something like that. Must be hard to find the correct balance between to many local var to keep an easy to read code and no local var.
16th Mar 2017, 5:54 PM
Geoffrey L
Geoffrey L - avatar