mirror of
https://github.com/nodejs/node.git
synced 2026-10-14 10:26:26 -04:00
lib: copy arguments object instead of leaking it
Instead of leaking the arguments object by passing it as an argument to a function, copy it's contents to a new array, then pass the array. This allows V8 to optimize the function that contains this code, improving performance. PR-URL: https://github.com/nodejs/node/pull/4361 Reviewed-By: James M Snell <jasnell@gmail.com> Reviewed-By: Brian White <mscdex@mscdex.net>
This commit is contained in:
1 parent
0ea3899cab
commit
d0582ef9e1
5 files changed
+43
-14
No files matched your search
+4
-1
@@ -85,7 +85,10 @@ Console.prototype.trace = function trace() {
|
||||
|
||||
Console.prototype.assert = function(expression) {
|
||||
if (!expression) {
|
||||
var arr = Array.prototype.slice.call(arguments, 1);
|
||||
const argsLen = arguments.length || 1;
|
||||
const arr = new Array(argsLen - 1);
|
||||
for (var i = 1; i < argsLen; i++)
|
||||
arr[i - 1] = arguments[i];
|
||||
require('assert').ok(false, util.format.apply(null, arr));
|
||||
}
|
||||
};
|
||||
|
||||
Reference in new issue
Block a user