From fe13e0077f5923e327465c9cd00d344cefee800f Mon Sep 17 00:00:00 2001 From: Anatoli Papirovski Date: Sun, 15 Oct 2017 01:21:34 -0400 Subject: [PATCH] events: onceWrapper apply directly with arguments Due to changes in V8 in 6.0 & 6.1, it's no longer necessary to copy arguments to avoid deopt. Just call .apply with arguments. Retains fast cases for 0-3 arguments. events/ee-once-4-args.js n=20000000 11.58 % *** 1.310379e-05 PR-URL: https://github.com/nodejs/node/pull/16212 Reviewed-By: Luigi Pinca Reviewed-By: Ruben Bridgewater Reviewed-By: James M Snell Reviewed-By: Refael Ackermann --- lib/events.js | 5 +---- 1 file changed, 1 insertion(+), 4 deletions(-) diff --git a/lib/events.js b/lib/events.js index 79a722674c3eea..6efc29108c30d2 100644 --- a/lib/events.js +++ b/lib/events.js @@ -328,10 +328,7 @@ function onceWrapper() { return this.listener.call(this.target, arguments[0], arguments[1], arguments[2]); default: - const args = new Array(arguments.length); - for (var i = 0; i < args.length; ++i) - args[i] = arguments[i]; - this.listener.apply(this.target, args); + this.listener.apply(this.target, arguments); } } }