From ec90cefdd917f626cf8d1ee4bd5744e41c075537 Mon Sep 17 00:00:00 2001 From: cjihrig Date: Thu, 27 Dec 2018 10:06:23 -0500 Subject: [PATCH] lib: simplify several debug() calls Avoid calling Array.prototype.join() in debug() calls. These are evaluated on every call, even if the debug() call is a no-op. This commit replaces the join() calls with the %j placeholder. PR-URL: https://github.com/nodejs/node/pull/25241 Reviewed-By: Ruben Bridgewater Reviewed-By: Anna Henningsen Reviewed-By: Luigi Pinca Reviewed-By: James M Snell --- lib/internal/http2/core.js | 4 ++-- lib/internal/modules/esm/create_dynamic_module.js | 4 +--- 2 files changed, 3 insertions(+), 5 deletions(-) diff --git a/lib/internal/http2/core.js b/lib/internal/http2/core.js index 5cabdb55b1d216..edc06e0ef870ae 100644 --- a/lib/internal/http2/core.js +++ b/lib/internal/http2/core.js @@ -470,8 +470,8 @@ function onOrigin(origins) { const session = this[kOwner]; if (session.destroyed) return; - debug(`Http2Session ${sessionName(session[kType])}: origin received: ` + - `${origins.join(', ')}`); + debug('Http2Session %s: origin received: %j', + sessionName(session[kType]), origins); session[kUpdateTimer](); if (!session.encrypted || session.destroyed) return undefined; diff --git a/lib/internal/modules/esm/create_dynamic_module.js b/lib/internal/modules/esm/create_dynamic_module.js index 8358016195f11d..d4356b4b673ae7 100644 --- a/lib/internal/modules/esm/create_dynamic_module.js +++ b/lib/internal/modules/esm/create_dynamic_module.js @@ -6,9 +6,7 @@ const ArrayJoin = Function.call.bind(Array.prototype.join); const ArrayMap = Function.call.bind(Array.prototype.map); const createDynamicModule = (exports, url = '', evaluate) => { - debug( - `creating ESM facade for ${url} with exports: ${ArrayJoin(exports, ', ')}` - ); + debug('creating ESM facade for %s with exports: %j', url, exports); const names = ArrayMap(exports, (name) => `${name}`); const source = `