Skip to content

Commit a4e2549

Browse files
mscdextargos
authored andcommitted
util: improve debuglog performance
PR-URL: #28956 Reviewed-By: James M Snell <[email protected]> Reviewed-By: Anto Aravinth <[email protected]> Reviewed-By: Michaël Zasso <[email protected]> Reviewed-By: Colin Ihrig <[email protected]> Reviewed-By: Joyee Cheung <[email protected]> Reviewed-By: Gus Caplan <[email protected]> Reviewed-By: Trivikram Kamat <[email protected]>
1 parent 1b6d7c0 commit a4e2549

File tree

1 file changed

+5
-4
lines changed

1 file changed

+5
-4
lines changed

lib/internal/util/debuglog.js

+5-4
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,7 @@ function emitWarningIfNeeded(set) {
3333

3434
function debuglogImpl(set) {
3535
set = set.toUpperCase();
36-
if (!debugs[set]) {
36+
if (debugs[set] === undefined) {
3737
if (debugEnvRegex.test(set)) {
3838
const pid = process.pid;
3939
emitWarningIfNeeded(set);
@@ -42,7 +42,7 @@ function debuglogImpl(set) {
4242
process.stderr.write(format('%s %d: %s\n', set, pid, msg));
4343
};
4444
} else {
45-
debugs[set] = function debug() {};
45+
debugs[set] = null;
4646
}
4747
}
4848
return debugs[set];
@@ -55,12 +55,13 @@ function debuglogImpl(set) {
5555
function debuglog(set) {
5656
let debug;
5757
return function(...args) {
58-
if (!debug) {
58+
if (debug === undefined) {
5959
// Only invokes debuglogImpl() when the debug function is
6060
// called for the first time.
6161
debug = debuglogImpl(set);
6262
}
63-
debug(...args);
63+
if (debug !== null)
64+
debug(...args);
6465
};
6566
}
6667

0 commit comments

Comments
 (0)