|
|
|
|
|
by willwagner
5445 days ago
|
|
Just to highlight what for me was non-obvious but interesting. It implies that this change in two places made a significant improvement to their performance stats. Basically, the optimizing compiler is finicky about the arguments object especially if it is used out of bounds. Without that knowledge, the change seems non-intuitive. I wonder if this true for all pseudo-arrays? Old Code: var args = Array.prototype.slice.call(arguments, 1);
New Code: var l = arguments.length;
var args = new Array(l - 1);
for (var i = 1; i < l; i++) args[i - 1] = arguments[i];
|
|
What optimizing compiler tries to do is to avoid creating arguments object and rewrite simple uses (simple is defined in the referenced post) to operate directly on the stack instead of creating and passing around real object. I should probably do yet another post about that but now with some assembly (but my battery is running low atm) :-)
Doing something like:
this use is not simple so compiler just gives up. But theoretically compiler could have inlined slice and looked one level deeper to see that.