Hi ..
I find this result quite surprising but also very interesting.
https://jsperf.com/function-calls-direct-vs-apply-vs-call-vs-bind/6
But following this result, I ask myself an anecdotal question.
I would like to reassure myself that I understood the principle of performance.
I use a lot of hud with lots complex animation, and I find myself having to duplicate inside objects, lots of clone function that this repeats from one object to another.
I would purify the codes, but I am falling on this resulta that left me puzzled.
In my context as an example.
So, example here, I have this.
Code:
//1: OUTSIDE: //EXAMPLE STATUS() ARE IN EATCH OBJ
//WHEN GAME BOOT BUILD THIS
$gameVariables.obj1 = new obj1(NewPid);
$gameVariables.obj2 = new obj2(NewPid);
$gameVariables.obj3 = new obj3(NewPid);
//CONSTRUCTOR
function obj1(NewPid) {
//EXAMPLE STATUS ARE INSIDE EATCH OBJ
this.Status = function(){if($gameScreen._pictures[this.Pid()]!==undefined){return true;}return false;}
this.Pid = function() { return this.NewPid }; // RETURN INITIAL PID
}
function obj2(NewPid) {
//EXAMPLE STATUS ARE INSIDE EATCH OBJ
this.Status = function(){if($gameScreen._pictures[this.Pid()]!==undefined){return true;}return false;}
this.Pid = function() { return this.NewPid }; // RETURN INITIAL PID
}
function obj......(NewPid) {
}
//__________________________________________________________________________________________________
//2: OUTSIDE: //EXAMPLE STATUS() ARE NOT IN EATCH OBJ AND ARE CALLED FROM OUTSIDE
GetStatusInObject = function(){
if($gameScreen._pictures[this.Pid()]!==undefined){return true;}return false;
}
GetStatusInObject.call(obj1);
The second technique is, therefore, cleaner, but much less performance effective in theory?
So the direct method will remain more logical, even if I have to repeat some cloning functions in the constructor. ?
It is not the weight that disturbs me, but rather the performances for access to information