Skip to content

Commit be07458

Browse files
bengljasnell
authored andcommitted
util: don't init Debug if it's not needed yet
Because any call to util.inspect() with an object results in inspectPromise() being called, Debug was being initialized even when it's not needed. Instead, the initialization is placed after the isPromise check. PR-URL: #8452 Reviewed-By: Anna Henningsen <[email protected]> Reviewed-By: James M Snell <[email protected]> Reviewed-By: Ben Noordhuis <[email protected]> Reviewed-By: Colin Ihrig <[email protected]> Reviewed-By: Sakthipriyan Vairamani <[email protected]> Reviewed-By: Evan Lucas <[email protected]>
1 parent fffb9a3 commit be07458

File tree

1 file changed

+1
-1
lines changed

1 file changed

+1
-1
lines changed

lib/util.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -289,10 +289,10 @@ function ensureDebugIsInitialized() {
289289

290290

291291
function inspectPromise(p) {
292-
ensureDebugIsInitialized();
293292
// Only create a mirror if the object is a Promise.
294293
if (!binding.isPromise(p))
295294
return null;
295+
ensureDebugIsInitialized();
296296
const mirror = Debug.MakeMirror(p, true);
297297
return {status: mirror.status(), value: mirror.promiseValue().value_};
298298
}

0 commit comments

Comments
 (0)