Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

Commit f36bee4

Browse filesBrowse files
fengmk2aduh95
authored andcommitted
util: avoid run debug when enabled is false
it can improve performace 700x faster PR-URL: #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>
1 parent 87e0dda commit f36bee4
Copy full SHA for f36bee4

File tree

Expand file treeCollapse file tree

1 file changed

+3
-1
lines changed
Open diff view settings
Filter options
Expand file treeCollapse file tree

1 file changed

+3
-1
lines changed
Open diff view settings
Collapse file

‎lib/internal/util/debuglog.js‎

Copy file name to clipboardExpand all lines: lib/internal/util/debuglog.js
+3-1Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -62,7 +62,7 @@ function lazyUtilColors() {
6262
return utilColors;
6363
}
6464

65-
function debuglogImpl(enabled, set, args) {
65+
function debuglogImpl(enabled, set) {
6666
if (debugImpls[set] === undefined) {
6767
if (enabled) {
6868
const pid = process.pid;
@@ -109,6 +109,8 @@ function debuglog(set, cb) {
109109
return enabled;
110110
};
111111
const logger = (...args) => {
112+
// Improve performance when debug is disabled, avoid calling `new SafeArrayIterator(args)`
113+
if (enabled === false) return;
112114
switch (args.length) {
113115
case 1: return debug(args[0]);
114116
case 2: return debug(args[0], args[1]);

0 commit comments

Comments
0 (0)
Morty Proxy This is a proxified and sanitized view of the page, visit original site.