Skip to content

Commit 38be155

Browse files
benglFishrock123
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 <anna@addaleax.net> Reviewed-By: James M Snell <jasnell@gmail.com> Reviewed-By: Ben Noordhuis <info@bnoordhuis.nl> Reviewed-By: Colin Ihrig <cjihrig@gmail.com> Reviewed-By: Sakthipriyan Vairamani <thechargingvolcano@gmail.com> Reviewed-By: Evan Lucas <evanlucas@me.com>
1 parent 52f0f64 commit 38be155

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)