diff --git a/lib/internal/util/debuglog.js b/lib/internal/util/debuglog.js index 96b10c4bbac767..3c8328b31b5565 100644 --- a/lib/internal/util/debuglog.js +++ b/lib/internal/util/debuglog.js @@ -62,7 +62,7 @@ function lazyUtilColors() { return utilColors; } -function debuglogImpl(enabled, set, args) { +function debuglogImpl(enabled, set) { if (debugImpls[set] === undefined) { if (enabled) { const pid = process.pid; @@ -109,6 +109,8 @@ function debuglog(set, cb) { return enabled; }; const logger = (...args) => { + // Improve performance when debug is disabled, avoid calling `new SafeArrayIterator(args)` + if (enabled === false) return; switch (args.length) { case 1: return debug(args[0]); case 2: return debug(args[0], args[1]);