Skip to content

Commit 2c84601

Browse files
benglMylesBorins
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 f854d8c commit 2c84601

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
@@ -231,10 +231,10 @@ function ensureDebugIsInitialized() {
231231

232232

233233
function inspectPromise(p) {
234-
ensureDebugIsInitialized();
235234
// Only create a mirror if the object is a Promise.
236235
if (!binding.isPromise(p))
237236
return null;
237+
ensureDebugIsInitialized();
238238
const mirror = Debug.MakeMirror(p, true);
239239
return {status: mirror.status(), value: mirror.promiseValue().value_};
240240
}

0 commit comments

Comments
 (0)