mirror of
https://github.com/zebrajr/node.git
synced 2026-01-15 12:15:26 +00:00
util: avoid run debug when enabled is false
it can improve performace 700x faster PR-URL: https://github.com/nodejs/node/pull/57494 Reviewed-By: Yagiz Nizipli <yagiz@nizipli.com> Reviewed-By: Colin Ihrig <cjihrig@gmail.com> Reviewed-By: James M Snell <jasnell@gmail.com> Reviewed-By: Jordan Harband <ljharb@gmail.com>
This commit is contained in:
@@ -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]);
|
||||
|
||||
Reference in New Issue
Block a user